Skip to content

Commit cd7ab5b

Browse files
authored
Merge pull request #643 from saschanaz/add-svg
fix: redefine ElementTagNameMap to fix SVGElementTagNameMap
2 parents 044d917 + 028a0a9 commit cd7ab5b

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

baselines/dom.generated.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4366,10 +4366,6 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par
43664366
*/
43674367
createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement;
43684368
createElementNS<K extends keyof SVGElementTagNameMap>(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: K): SVGElementTagNameMap[K];
4369-
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement;
4370-
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "script"): SVGScriptElement;
4371-
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "style"): SVGStyleElement;
4372-
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "title"): SVGTitleElement;
43734369
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement;
43744370
createElementNS(namespaceURI: string | null, qualifiedName: string, options?: ElementCreationOptions): Element;
43754371
createElementNS(namespace: string | null, qualifiedName: string, options?: string | ElementCreationOptions): Element;
@@ -17728,6 +17724,7 @@ interface HTMLElementDeprecatedTagNameMap {
1772817724
}
1772917725

1773017726
interface SVGElementTagNameMap {
17727+
"a": SVGAElement;
1773117728
"circle": SVGCircleElement;
1773217729
"clipPath": SVGClipPathElement;
1773317730
"defs": SVGDefsElement;
@@ -17772,19 +17769,22 @@ interface SVGElementTagNameMap {
1777217769
"polyline": SVGPolylineElement;
1777317770
"radialGradient": SVGRadialGradientElement;
1777417771
"rect": SVGRectElement;
17772+
"script": SVGScriptElement;
1777517773
"stop": SVGStopElement;
17774+
"style": SVGStyleElement;
1777617775
"svg": SVGSVGElement;
1777717776
"switch": SVGSwitchElement;
1777817777
"symbol": SVGSymbolElement;
1777917778
"text": SVGTextElement;
1778017779
"textPath": SVGTextPathElement;
17780+
"title": SVGTitleElement;
1778117781
"tspan": SVGTSpanElement;
1778217782
"use": SVGUseElement;
1778317783
"view": SVGViewElement;
1778417784
}
1778517785

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

1778917789
declare var Audio: {
1779017790
new(src?: string): HTMLAudioElement;

inputfiles/addedTypes.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,10 +718,6 @@
718718
"additional-signatures": [
719719
"createElementNS(namespaceURI: \"http://www.w3.org/1999/xhtml\", qualifiedName: string): HTMLElement",
720720
"createElementNS<K extends keyof SVGElementTagNameMap>(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: K): SVGElementTagNameMap[K]",
721-
"createElementNS(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: \"a\"): SVGAElement",
722-
"createElementNS(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: \"script\"): SVGScriptElement",
723-
"createElementNS(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: \"style\"): SVGStyleElement",
724-
"createElementNS(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: \"title\"): SVGTitleElement",
725721
"createElementNS(namespaceURI: \"http://www.w3.org/2000/svg\", qualifiedName: string): SVGElement",
726722
"createElementNS(namespaceURI: string | null, qualifiedName: string, options?: ElementCreationOptions): Element"
727723
]

src/emitter.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,6 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
456456
printer.printLine("interface SVGElementTagNameMap {");
457457
printer.increaseIndent();
458458
for (const [e, value] of Object.entries(tagNameToEleName.svgResult).sort()) {
459-
if (e in tagNameToEleName.htmlResult) {
460-
// Skip conflicting fields with HTMLElementTagNameMap
461-
// to be compatible with deprecated ElementTagNameMap
462-
continue;
463-
}
464459
printer.printLine(`"${e}": ${value};`);
465460
}
466461
printer.decreaseIndent();
@@ -470,7 +465,7 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
470465

471466
function emitElementTagNameMap() {
472467
printer.printLine("/** @deprecated Directly use HTMLElementTagNameMap or SVGElementTagNameMap as appropriate, instead. */");
473-
printer.printLine("interface ElementTagNameMap extends HTMLElementTagNameMap, SVGElementTagNameMap { }");
468+
printer.printLine("type ElementTagNameMap = HTMLElementTagNameMap & Pick<SVGElementTagNameMap, Exclude<keyof SVGElementTagNameMap, keyof HTMLElementTagNameMap>>;");
474469
printer.printLine("");
475470
}
476471

0 commit comments

Comments
 (0)