Skip to content

fix(dom): narrow ownerDocument in specific Node interfaces #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2165,6 +2165,7 @@ interface Attr extends Node {
readonly localName: string;
readonly name: string;
readonly namespaceURI: string | null;
readonly ownerDocument: Document;
readonly ownerElement: Element | null;
readonly prefix: string | null;
readonly specified: boolean;
Expand Down Expand Up @@ -3454,6 +3455,7 @@ declare var ChannelSplitterNode: {
interface CharacterData extends Node, ChildNode, NonDocumentTypeChildNode {
data: string;
readonly length: number;
readonly ownerDocument: Document;
appendData(data: string): void;
cloneNode(deep?: boolean): CharacterData;
deleteData(offset: number, count: number): void;
Expand Down Expand Up @@ -4529,6 +4531,7 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad
* Returns document's origin.
*/
readonly origin: string;
readonly ownerDocument: null;
/**
* Return an HTMLCollection of the embed elements in the Document.
*/
Expand Down Expand Up @@ -4953,6 +4956,7 @@ interface DocumentEvent {

/** 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. */
interface DocumentFragment extends Node, NonElementParentNode, ParentNode {
readonly ownerDocument: Document;
cloneNode(deep?: boolean): DocumentFragment;
getElementById(elementId: string): HTMLElement | null;
}
Expand Down Expand Up @@ -4992,6 +4996,7 @@ declare var DocumentTimeline: {
/** A Node containing a doctype. */
interface DocumentType extends Node, ChildNode {
readonly name: string;
readonly ownerDocument: Document;
readonly publicId: string;
readonly systemId: string;
cloneNode(deep?: boolean): DocumentType;
Expand Down Expand Up @@ -5091,6 +5096,7 @@ interface Element extends Node, Animatable, ChildNode, InnerHTML, NonDocumentTyp
onfullscreenchange: ((this: Element, ev: Event) => any) | null;
onfullscreenerror: ((this: Element, ev: Event) => any) | null;
outerHTML: string;
readonly ownerDocument: Document;
/**
* Returns the namespace prefix.
*/
Expand Down Expand Up @@ -11843,6 +11849,7 @@ interface PositionError {

/** A processing instruction embeds application-specific instructions in XML which can be ignored by other applications that don't recognize them. */
interface ProcessingInstruction extends CharacterData, LinkStyle {
readonly ownerDocument: Document;
readonly target: string;
cloneNode(deep?: boolean): ProcessingInstruction;
}
Expand Down
59 changes: 59 additions & 0 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,11 @@
"read-only": 1,
"override-type": "HTMLSlotElement | null"
},
"ownerDocument": {
"name": "ownerDocument",
"read-only": 1,
"override-type": "Document"
},
"slot": {
"name": "slot",
"override-type": "string"
Expand Down Expand Up @@ -720,6 +725,15 @@
"type": "Event"
}
]
},
"properties": {
"property": {
"ownerDocument": {
"name": "ownerDocument",
"read-only": 1,
"override-type": "null"
}
}
}
},
"Navigator": {
Expand Down Expand Up @@ -1072,6 +1086,15 @@
]
}
}
},
"properties": {
"property": {
"ownerDocument": {
"name": "ownerDocument",
"read-only": 1,
"override-type": "Document"
}
}
}
},
"SpeechRecognition": {
Expand Down Expand Up @@ -3284,6 +3307,15 @@
]
}
}
},
"properties": {
"property": {
"ownerDocument": {
"name": "ownerDocument",
"read-only": 1,
"override-type": "Document"
}
}
}
},
"CDATASection": {
Expand All @@ -3310,6 +3342,15 @@
]
}
}
},
"properties": {
"property": {
"ownerDocument": {
"name": "ownerDocument",
"read-only": 1,
"override-type": "Document"
}
}
}
},
"Comment": {
Expand All @@ -3336,6 +3377,15 @@
]
}
}
},
"properties": {
"property": {
"ownerDocument": {
"name": "ownerDocument",
"read-only": 1,
"override-type": "Document"
}
}
}
},
"HTMLAppletElement": {
Expand Down Expand Up @@ -3674,6 +3724,15 @@
]
}
}
},
"properties": {
"property": {
"ownerDocument": {
"name": "ownerDocument",
"read-only": 1,
"override-type": "Document"
}
}
}
},
"ShadowRoot": {
Expand Down