Skip to content

fix: redefine ElementTagNameMap to fix SVGElementTagNameMap #643

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
Feb 13, 2019
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
10 changes: 5 additions & 5 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4366,10 +4366,6 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par
*/
createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement;
createElementNS<K extends keyof SVGElementTagNameMap>(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: K): SVGElementTagNameMap[K];
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement;
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "script"): SVGScriptElement;
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "style"): SVGStyleElement;
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "title"): SVGTitleElement;
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement;
createElementNS(namespaceURI: string | null, qualifiedName: string, options?: ElementCreationOptions): Element;
createElementNS(namespace: string | null, qualifiedName: string, options?: string | ElementCreationOptions): Element;
Expand Down Expand Up @@ -17728,6 +17724,7 @@ interface HTMLElementDeprecatedTagNameMap {
}

interface SVGElementTagNameMap {
"a": SVGAElement;
"circle": SVGCircleElement;
"clipPath": SVGClipPathElement;
"defs": SVGDefsElement;
Expand Down Expand Up @@ -17772,19 +17769,22 @@ interface SVGElementTagNameMap {
"polyline": SVGPolylineElement;
"radialGradient": SVGRadialGradientElement;
"rect": SVGRectElement;
"script": SVGScriptElement;
"stop": SVGStopElement;
"style": SVGStyleElement;
"svg": SVGSVGElement;
"switch": SVGSwitchElement;
"symbol": SVGSymbolElement;
"text": SVGTextElement;
"textPath": SVGTextPathElement;
"title": SVGTitleElement;
"tspan": SVGTSpanElement;
"use": SVGUseElement;
"view": SVGViewElement;
}

/** @deprecated Directly use HTMLElementTagNameMap or SVGElementTagNameMap as appropriate, instead. */
interface ElementTagNameMap extends HTMLElementTagNameMap, SVGElementTagNameMap { }
type ElementTagNameMap = HTMLElementTagNameMap & Pick<SVGElementTagNameMap, Exclude<keyof SVGElementTagNameMap, keyof HTMLElementTagNameMap>>;

declare var Audio: {
new(src?: string): HTMLAudioElement;
Expand Down
4 changes: 0 additions & 4 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,6 @@
"additional-signatures": [
"createElementNS(namespaceURI: \"http://www.w3.org/1999/xhtml\", qualifiedName: string): HTMLElement",
"createElementNS<K extends keyof SVGElementTagNameMap>(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: K): SVGElementTagNameMap[K]",
"createElementNS(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: \"a\"): SVGAElement",
"createElementNS(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: \"script\"): SVGScriptElement",
"createElementNS(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: \"style\"): SVGStyleElement",
"createElementNS(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: \"title\"): SVGTitleElement",
"createElementNS(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: string): SVGElement",
"createElementNS(namespaceURI: string | null, qualifiedName: string, options?: ElementCreationOptions): Element"
]
Expand Down
7 changes: 1 addition & 6 deletions src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,6 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
printer.printLine("interface SVGElementTagNameMap {");
printer.increaseIndent();
for (const [e, value] of Object.entries(tagNameToEleName.svgResult).sort()) {
if (e in tagNameToEleName.htmlResult) {
// Skip conflicting fields with HTMLElementTagNameMap
// to be compatible with deprecated ElementTagNameMap
continue;
}
printer.printLine(`"${e}": ${value};`);
}
printer.decreaseIndent();
Expand All @@ -470,7 +465,7 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {

function emitElementTagNameMap() {
printer.printLine("/** @deprecated Directly use HTMLElementTagNameMap or SVGElementTagNameMap as appropriate, instead. */");
printer.printLine("interface ElementTagNameMap extends HTMLElementTagNameMap, SVGElementTagNameMap { }");
printer.printLine("type ElementTagNameMap = HTMLElementTagNameMap & Pick<SVGElementTagNameMap, Exclude<keyof SVGElementTagNameMap, keyof HTMLElementTagNameMap>>;");
printer.printLine("");
}

Expand Down