From c81fa761df9c4483cd7f5d9767415660d4f1ee90 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Wed, 6 Jan 2021 15:44:36 +0000 Subject: [PATCH] Revert "Replaces several DOM methods with weaker typings and closes microsoft/TypeScript#4689" --- baselines/dom.generated.d.ts | 18 +++----- inputfiles/addedTypes.json | 4 +- inputfiles/overridingTypes.json | 78 ++------------------------------- 3 files changed, 12 insertions(+), 88 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index def48d12b..7b0b1bbf6 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -4830,11 +4830,11 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad * Returns a reference to the first object with the specified value of the ID attribute. * @param elementId String that specifies the ID value. */ - getElementById(elementId: string): E | null; + getElementById(elementId: string): HTMLElement | null; /** * Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. */ - getElementsByClassName(classNames: string): HTMLCollectionOf; + getElementsByClassName(classNames: string): HTMLCollectionOf; /** * Gets a collection of objects based on the value of the NAME or ID attribute. * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. @@ -5030,7 +5030,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; - getElementById(elementId: string): E | null; + getElementById(elementId: string): HTMLElement | null; } declare var DocumentFragment: { @@ -5216,7 +5216,7 @@ interface Element extends Node, Animatable, ChildNode, InnerHTML, NonDocumentTyp /** * Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. */ - getElementsByClassName(classNames: string): HTMLCollectionOf; + getElementsByClassName(classNames: string): HTMLCollectionOf; getElementsByTagName(qualifiedName: K): HTMLCollectionOf; getElementsByTagName(qualifiedName: K): HTMLCollectionOf; getElementsByTagName(qualifiedName: string): HTMLCollectionOf; @@ -6671,7 +6671,6 @@ interface HTMLElement extends Element, DocumentAndElementEventHandlers, ElementC readonly offsetParent: Element | null; readonly offsetTop: number; readonly offsetWidth: number; - readonly parentElement: HTMLElement | null; spellcheck: boolean; title: string; translate: boolean; @@ -10865,7 +10864,7 @@ interface Node extends EventTarget { /** * Returns the parent element. */ - readonly parentElement: Element | null; + readonly parentElement: HTMLElement | null; /** * Returns the parent. */ @@ -11123,7 +11122,7 @@ interface NonElementParentNode { /** * Returns the first element within node's descendants whose ID is elementId. */ - getElementById(elementId: string): E | null; + getElementById(elementId: string): Element | null; } interface NotificationEventMap { @@ -13052,9 +13051,7 @@ interface SVGElement extends Element, DocumentAndElementEventHandlers, DocumentA /** @deprecated */ readonly className: any; readonly ownerSVGElement: SVGSVGElement | null; - readonly parentElement: SVGElement | null; readonly viewportElement: SVGElement | null; - getElementsByClassName(classNames: string): HTMLCollectionOf; addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -13642,7 +13639,6 @@ interface SVGForeignObjectElement extends SVGGraphicsElement { readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - getElementsByClassName(classNames: string): HTMLCollectionOf; addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -14446,7 +14442,7 @@ interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewB forceRedraw(): void; getComputedStyle(elt: Element, pseudoElt?: string | null): CSSStyleDeclaration; getCurrentTime(): number; - getElementById(elementId: string): E | null; + getElementById(elementId: string): Element; getEnclosureList(rect: SVGRect, referenceElement: SVGElement | null): NodeListOf; getIntersectionList(rect: SVGRect, referenceElement: SVGElement | null): NodeListOf; pauseAnimations(): void; diff --git a/inputfiles/addedTypes.json b/inputfiles/addedTypes.json index 9f503f568..65b358a25 100644 --- a/inputfiles/addedTypes.json +++ b/inputfiles/addedTypes.json @@ -626,7 +626,7 @@ "getElementsByClassName": { "name": "getElementsByClassName", "override-signatures": [ - "getElementsByClassName(classNames: string): HTMLCollectionOf" + "getElementsByClassName(classNames: string): HTMLCollectionOf" ] }, "closest": { @@ -988,7 +988,7 @@ "name": "getElementById", "exposed": "Window", "override-signatures": [ - "getElementById(elementId: string): E | null" + "getElementById(elementId: string): HTMLElement | null" ] } } diff --git a/inputfiles/overridingTypes.json b/inputfiles/overridingTypes.json index e022959bf..5a6428cd9 100644 --- a/inputfiles/overridingTypes.json +++ b/inputfiles/overridingTypes.json @@ -1,32 +1,6 @@ { "mixins": { "mixin": { - "NonElementParentNode": { - "name": "NonElementParentNode", - "methods": { - "method": { - "getElementById": { - "name": "getElementById", - "override-signatures": [ - "getElementById(elementId: string): E | null" - ] - } - } - } - }, - "GlobalFetch": { - "name": "GlobalFetch", - "methods": { - "method": { - "fetch": { - "name": "fetch", - "override-signatures": [ - "fetch(input: RequestInfo, init?: RequestInit): Promise" - ] - } - } - } - }, "Animatable": { "name": "Animatable", "methods": { @@ -528,18 +502,6 @@ }, "override-index-signatures": [] }, - "HTMLElement": { - "name": "HTMLElement", - "properties": { - "property": { - "parentElement": { - "name": "parentElement", - "read-only": 1, - "override-type": "HTMLElement | null" - } - } - } - }, "Document": { "name": "Document", "methods": { @@ -565,7 +527,7 @@ "getElementById": { "name": "getElementById", "override-signatures": [ - "getElementById(elementId: string): E | null" + "getElementById(elementId: string): HTMLElement | null" ] }, "getElementsByTagNameNS": { @@ -579,7 +541,7 @@ "getElementsByClassName": { "name": "getElementsByClassName", "override-signatures": [ - "getElementsByClassName(classNames: string): HTMLCollectionOf" + "getElementsByClassName(classNames: string): HTMLCollectionOf" ] }, "getElementsByName": { @@ -728,7 +690,7 @@ "override-type": "Node & ParentNode | null" }, "parentElement": { - "override-type": "Element | null" + "override-type": "HTMLElement | null" }, "childNodes": { "override-type": "NodeListOf" @@ -939,21 +901,6 @@ "deprecated": 1, "name": "className", "type": "any" - }, - "parentElement": { - "name": "parentElement", - "read-only": 1, - "override-type": "SVGElement | null" - } - } - }, - "methods": { - "method": { - "getElementsByClassName": { - "name": "getElementsByClassName", - "override-signatures": [ - "getElementsByClassName(classNames: string): HTMLCollectionOf" - ] } } } @@ -962,12 +909,6 @@ "name": "SVGSVGElement", "methods": { "method": { - "getElementById": { - "name": "getElementById", - "override-signatures": [ - "getElementById(elementId: string): E | null" - ] - }, "getEnclosureList": { "name": "getEnclosureList", "override-signatures": [ @@ -999,19 +940,6 @@ } } }, - "SVGForeignObjectElement": { - "name": "SVGForeignObjectElement", - "methods": { - "method": { - "getElementsByClassName": { - "name": "getElementsByClassName", - "override-signatures": [ - "getElementsByClassName(classNames: string): HTMLCollectionOf" - ] - } - } - } - }, "FormData": { "name": "FormData", "methods": {