Skip to content

Remove ElementTagNameMap #326

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 2 commits into from
Nov 21, 2017
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
21 changes: 6 additions & 15 deletions TS.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -793,19 +793,22 @@ module Emit =
/// Emit overloads for the getElementsByTagName method
let EmitGetElementsByTagNameOverloads (m: Browser.Method) =
if matchSingleParamMethodSignature m "getElementsByTagName" "NodeList" "string" then
Pt.Printl "getElementsByTagName<K extends keyof ElementListTagNameMap>(%s: K): ElementListTagNameMap[K];" m.Params.[0].Name
Pt.Printl "getElementsByTagName<K extends keyof HTMLElementTagNameMap>(%s: K): NodeListOf<HTMLElementTagNameMap[K]>;" m.Params.[0].Name
Pt.Printl "getElementsByTagName<K extends keyof SVGElementTagNameMap>(%s: K): NodeListOf<SVGElementTagNameMap[K]>;" m.Params.[0].Name
Pt.Printl "getElementsByTagName(%s: string): NodeListOf<Element>;" m.Params.[0].Name

/// Emit overloads for the querySelector method
let EmitQuerySelectorOverloads (m: Browser.Method) =
if matchSingleParamMethodSignature m "querySelector" "Element" "string" then
Pt.Printl "querySelector<K extends keyof ElementTagNameMap>(selectors: K): ElementTagNameMap[K] | null;"
Pt.Printl "querySelector<K extends keyof HTMLElementTagNameMap>(selectors: K): HTMLElementTagNameMap[K] | null;"
Pt.Printl "querySelector<K extends keyof SVGElementTagNameMap>(selectors: K): SVGElementTagNameMap[K] | null;"
Pt.Printl "querySelector<E extends Element = Element>(selectors: string): E | null;"

/// Emit overloads for the querySelectorAll method
let EmitQuerySelectorAllOverloads (m: Browser.Method) =
if matchSingleParamMethodSignature m "querySelectorAll" "NodeList" "string" then
Pt.Printl "querySelectorAll<K extends keyof ElementListTagNameMap>(selectors: K): ElementListTagNameMap[K];"
Pt.Printl "querySelectorAll<K extends keyof HTMLElementTagNameMap>(selectors: K): NodeListOf<HTMLElementTagNameMap[K]>;"
Pt.Printl "querySelectorAll<K extends keyof SVGElementTagNameMap>(selectors: K): NodeListOf<SVGElementTagNameMap[K]>;"
Pt.Printl "querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;"

let EmitHTMLElementTagNameMap () =
Expand All @@ -828,16 +831,6 @@ module Emit =
Pt.Printl "}"
Pt.Printl ""

let EmitElementTagNameMap () =
Pt.Printl "interface ElementTagNameMap extends HTMLElementTagNameMap, SVGElementTagNameMap { }"
Pt.Printl ""

let EmitElementListTagNameMap () =
Pt.Printl "type ElementListTagNameMap = {"
Pt.PrintWithAddedIndent "[key in keyof ElementTagNameMap]: NodeListOf<ElementTagNameMap[key]>"
Pt.Printl "};"
Pt.Printl ""

/// Emit overloads for the createEvent method
let EmitCreateEventOverloads (m: Browser.Method) =
if matchSingleParamMethodSignature m "createEvent" "Event" "string" then
Expand Down Expand Up @@ -1521,8 +1514,6 @@ module Emit =
if flavor <> Worker then
EmitHTMLElementTagNameMap()
EmitSVGElementTagNameMap()
EmitElementTagNameMap()
EmitElementListTagNameMap()
EmitNamedConstructors()

match GetGlobalPollutor flavor with
Expand Down
21 changes: 10 additions & 11 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3243,7 +3243,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
* Retrieves a collection of objects based on the specified element name.
* @param name Specifies the name of an element.
*/
getElementsByTagName<K extends keyof ElementListTagNameMap>(tagname: K): ElementListTagNameMap[K];
getElementsByTagName<K extends keyof HTMLElementTagNameMap>(tagname: K): NodeListOf<HTMLElementTagNameMap[K]>;
getElementsByTagName<K extends keyof SVGElementTagNameMap>(tagname: K): NodeListOf<SVGElementTagNameMap[K]>;
getElementsByTagName(tagname: string): NodeListOf<Element>;
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf<HTMLElement>;
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>;
Expand Down Expand Up @@ -3600,7 +3601,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
getAttributeNS(namespaceURI: string, localName: string): string;
getBoundingClientRect(): ClientRect;
getClientRects(): ClientRectList;
getElementsByTagName<K extends keyof ElementListTagNameMap>(name: K): ElementListTagNameMap[K];
getElementsByTagName<K extends keyof HTMLElementTagNameMap>(name: K): NodeListOf<HTMLElementTagNameMap[K]>;
getElementsByTagName<K extends keyof SVGElementTagNameMap>(name: K): NodeListOf<SVGElementTagNameMap[K]>;
getElementsByTagName(name: string): NodeListOf<Element>;
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf<HTMLElement>;
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>;
Expand Down Expand Up @@ -3629,7 +3631,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
webkitRequestFullScreen(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
matches(selector: string): boolean;
closest<K extends keyof ElementTagNameMap>(selector: K): ElementTagNameMap[K] | null;
closest<K extends keyof HTMLElementTagNameMap>(selector: K): HTMLElementTagNameMap[K] | null;
closest<K extends keyof SVGElementTagNameMap>(selector: K): SVGElementTagNameMap[K] | null;
closest(selector: string): Element | null;
scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void;
scroll(options?: ScrollToOptions): void;
Expand Down Expand Up @@ -14131,9 +14134,11 @@ interface NavigatorUserMedia {
}

interface NodeSelector {
querySelector<K extends keyof ElementTagNameMap>(selectors: K): ElementTagNameMap[K] | null;
querySelector<K extends keyof HTMLElementTagNameMap>(selectors: K): HTMLElementTagNameMap[K] | null;
querySelector<K extends keyof SVGElementTagNameMap>(selectors: K): SVGElementTagNameMap[K] | null;
querySelector<E extends Element = Element>(selectors: string): E | null;
querySelectorAll<K extends keyof ElementListTagNameMap>(selectors: K): ElementListTagNameMap[K];
querySelectorAll<K extends keyof HTMLElementTagNameMap>(selectors: K): NodeListOf<HTMLElementTagNameMap[K]>;
querySelectorAll<K extends keyof SVGElementTagNameMap>(selectors: K): NodeListOf<SVGElementTagNameMap[K]>;
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
}

Expand Down Expand Up @@ -15024,12 +15029,6 @@ interface SVGElementTagNameMap {
"view": SVGViewElement;
}

interface ElementTagNameMap extends HTMLElementTagNameMap, SVGElementTagNameMap { }

type ElementListTagNameMap = {
[key in keyof ElementTagNameMap]: NodeListOf<ElementTagNameMap[key]>
};

declare var Audio: { new(src?: string): HTMLAudioElement; };
declare var Image: { new(width?: number, height?: number): HTMLImageElement; };
declare var Option: { new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; };
Expand Down
3 changes: 2 additions & 1 deletion inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@
"kind": "method",
"interface": "Element",
"signatures": [
"closest<K extends keyof ElementTagNameMap>(selector: K): ElementTagNameMap[K] | null"
"closest<K extends keyof HTMLElementTagNameMap>(selector: K): HTMLElementTagNameMap[K] | null",
"closest<K extends keyof SVGElementTagNameMap>(selector: K): SVGElementTagNameMap[K] | null"
]
},
{
Expand Down