Skip to content

Commit af44ea1

Browse files
authored
fix(dom): narrow ownerDocument in specific Node interfaces (#819)
1 parent b430aa3 commit af44ea1

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

baselines/dom.generated.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,6 +2165,7 @@ interface Attr extends Node {
21652165
readonly localName: string;
21662166
readonly name: string;
21672167
readonly namespaceURI: string | null;
2168+
readonly ownerDocument: Document;
21682169
readonly ownerElement: Element | null;
21692170
readonly prefix: string | null;
21702171
readonly specified: boolean;
@@ -3454,6 +3455,7 @@ declare var ChannelSplitterNode: {
34543455
interface CharacterData extends Node, ChildNode, NonDocumentTypeChildNode {
34553456
data: string;
34563457
readonly length: number;
3458+
readonly ownerDocument: Document;
34573459
appendData(data: string): void;
34583460
cloneNode(deep?: boolean): CharacterData;
34593461
deleteData(offset: number, count: number): void;
@@ -4529,6 +4531,7 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad
45294531
* Returns document's origin.
45304532
*/
45314533
readonly origin: string;
4534+
readonly ownerDocument: null;
45324535
/**
45334536
* Return an HTMLCollection of the embed elements in the Document.
45344537
*/
@@ -4953,6 +4956,7 @@ interface DocumentEvent {
49534956

49544957
/** A minimal document object that has no parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document. The key difference is that because the document fragment isn't part of the active document tree structure, changes made to the fragment don't affect the document, cause reflow, or incur any performance impact that can occur when changes are made. */
49554958
interface DocumentFragment extends Node, NonElementParentNode, ParentNode {
4959+
readonly ownerDocument: Document;
49564960
cloneNode(deep?: boolean): DocumentFragment;
49574961
getElementById(elementId: string): HTMLElement | null;
49584962
}
@@ -4992,6 +4996,7 @@ declare var DocumentTimeline: {
49924996
/** A Node containing a doctype. */
49934997
interface DocumentType extends Node, ChildNode {
49944998
readonly name: string;
4999+
readonly ownerDocument: Document;
49955000
readonly publicId: string;
49965001
readonly systemId: string;
49975002
cloneNode(deep?: boolean): DocumentType;
@@ -5091,6 +5096,7 @@ interface Element extends Node, Animatable, ChildNode, InnerHTML, NonDocumentTyp
50915096
onfullscreenchange: ((this: Element, ev: Event) => any) | null;
50925097
onfullscreenerror: ((this: Element, ev: Event) => any) | null;
50935098
outerHTML: string;
5099+
readonly ownerDocument: Document;
50945100
/**
50955101
* Returns the namespace prefix.
50965102
*/
@@ -11843,6 +11849,7 @@ interface PositionError {
1184311849

1184411850
/** A processing instruction embeds application-specific instructions in XML which can be ignored by other applications that don't recognize them. */
1184511851
interface ProcessingInstruction extends CharacterData, LinkStyle {
11852+
readonly ownerDocument: Document;
1184611853
readonly target: string;
1184711854
cloneNode(deep?: boolean): ProcessingInstruction;
1184811855
}

inputfiles/addedTypes.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,11 @@
686686
"read-only": 1,
687687
"override-type": "HTMLSlotElement | null"
688688
},
689+
"ownerDocument": {
690+
"name": "ownerDocument",
691+
"read-only": 1,
692+
"override-type": "Document"
693+
},
689694
"slot": {
690695
"name": "slot",
691696
"override-type": "string"
@@ -720,6 +725,15 @@
720725
"type": "Event"
721726
}
722727
]
728+
},
729+
"properties": {
730+
"property": {
731+
"ownerDocument": {
732+
"name": "ownerDocument",
733+
"read-only": 1,
734+
"override-type": "null"
735+
}
736+
}
723737
}
724738
},
725739
"Navigator": {
@@ -1072,6 +1086,15 @@
10721086
]
10731087
}
10741088
}
1089+
},
1090+
"properties": {
1091+
"property": {
1092+
"ownerDocument": {
1093+
"name": "ownerDocument",
1094+
"read-only": 1,
1095+
"override-type": "Document"
1096+
}
1097+
}
10751098
}
10761099
},
10771100
"SpeechRecognition": {
@@ -3284,6 +3307,15 @@
32843307
]
32853308
}
32863309
}
3310+
},
3311+
"properties": {
3312+
"property": {
3313+
"ownerDocument": {
3314+
"name": "ownerDocument",
3315+
"read-only": 1,
3316+
"override-type": "Document"
3317+
}
3318+
}
32873319
}
32883320
},
32893321
"CDATASection": {
@@ -3310,6 +3342,15 @@
33103342
]
33113343
}
33123344
}
3345+
},
3346+
"properties": {
3347+
"property": {
3348+
"ownerDocument": {
3349+
"name": "ownerDocument",
3350+
"read-only": 1,
3351+
"override-type": "Document"
3352+
}
3353+
}
33133354
}
33143355
},
33153356
"Comment": {
@@ -3336,6 +3377,15 @@
33363377
]
33373378
}
33383379
}
3380+
},
3381+
"properties": {
3382+
"property": {
3383+
"ownerDocument": {
3384+
"name": "ownerDocument",
3385+
"read-only": 1,
3386+
"override-type": "Document"
3387+
}
3388+
}
33393389
}
33403390
},
33413391
"HTMLAppletElement": {
@@ -3674,6 +3724,15 @@
36743724
]
36753725
}
36763726
}
3727+
},
3728+
"properties": {
3729+
"property": {
3730+
"ownerDocument": {
3731+
"name": "ownerDocument",
3732+
"read-only": 1,
3733+
"override-type": "Document"
3734+
}
3735+
}
36773736
}
36783737
},
36793738
"ShadowRoot": {

0 commit comments

Comments
 (0)