File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed
Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -19836,7 +19836,7 @@ interface Node extends EventTarget {
1983619836 *
1983719837 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/parentElement)
1983819838 */
19839- readonly parentElement: HTMLElement | null;
19839+ readonly parentElement: Element | null;
1984019840 /**
1984119841 * Returns the parent.
1984219842 *
@@ -19941,6 +19941,12 @@ interface Node extends EventTarget {
1994119941 readonly DOCUMENT_POSITION_CONTAINED_BY: 0x10;
1994219942 readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 0x20;
1994319943}
19944+ // /**
19945+ // * Returns the parent element.
19946+ // *
19947+ // * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/parentElement)
19948+ // */
19949+ // readonly parentElement: HTMLElement | null;
1994419950
1994519951declare var Node: {
1994619952 prototype: Node;
Original file line number Diff line number Diff line change @@ -255,3 +255,12 @@ interface Document
255255interface DocumentFragment extends Node , NonElementParentNode , ParentNode {
256256 getElementById ( elementId : string ) : Element | null ;
257257}
258+
259+ interface Node extends EventTarget {
260+ /**
261+ * Returns the parent element.
262+ *
263+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/parentElement)
264+ */
265+ readonly parentElement : Element | null ;
266+ }
Original file line number Diff line number Diff line change @@ -161,3 +161,29 @@ const test = async (url: string) => {
161161 const svgElement : SVGElement = { } as SVGElement ;
162162 const elementOrNull : typeof element = svgElement ;
163163}
164+
165+ // Node.parentElement
166+ {
167+ const div = document . createElement ( "div" ) ;
168+ const parent = div . parentElement ;
169+ expectType < Element | null > ( parent ) ;
170+
171+ // Verify that the return type is not specifically HTMLElement
172+ expectNotType < HTMLElement | null > ( parent ) ;
173+
174+ // Verify that SVGElement can be assigned to parentElement (without type assertion)
175+ const svgElement : SVGElement = { } as SVGElement ;
176+ const elementOrNull : typeof parent = svgElement ;
177+
178+ // Test with SVG elements
179+ const svgElement2 = document . createElementNS ( "http://www.w3.org/2000/svg" , "circle" ) ;
180+ const svgParent = svgElement2 . parentElement ;
181+ expectType < Element | null > ( svgParent ) ;
182+
183+ // Verify SVG elements work with parentElement
184+ if ( svgParent ) {
185+ expectType < Element > ( svgParent ) ;
186+ // Should be able to call methods available on Element
187+ svgParent . getAttribute ( "id" ) ;
188+ }
189+ }
You can’t perform that action at this time.
0 commit comments