Skip to content
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
3 changes: 3 additions & 0 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11291,6 +11291,9 @@ interface Element extends Node, ARIAMixin, Animatable, ChildNode, NonDocumentTyp
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/matches)
*/
matches<K extends keyof HTMLElementTagNameMap>(selectors: K): this is HTMLElementTagNameMap[K];
matches<K extends keyof SVGElementTagNameMap>(selectors: K): this is SVGElementTagNameMap[K];
matches<K extends keyof MathMLElementTagNameMap>(selectors: K): this is MathMLElementTagNameMap[K];
matches(selectors: string): boolean;
/**
* The **`releasePointerCapture()`** method of the Element interface releases (stops) _pointer capture_ that was previously set for a specific (PointerEvent) _pointer_.
Expand Down
3 changes: 3 additions & 0 deletions baselines/ts5.5/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11281,6 +11281,9 @@ interface Element extends Node, ARIAMixin, Animatable, ChildNode, NonDocumentTyp
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/matches)
*/
matches<K extends keyof HTMLElementTagNameMap>(selectors: K): this is HTMLElementTagNameMap[K];
matches<K extends keyof SVGElementTagNameMap>(selectors: K): this is SVGElementTagNameMap[K];
matches<K extends keyof MathMLElementTagNameMap>(selectors: K): this is MathMLElementTagNameMap[K];
matches(selectors: string): boolean;
/**
* The **`releasePointerCapture()`** method of the Element interface releases (stops) _pointer capture_ that was previously set for a specific (PointerEvent) _pointer_.
Expand Down
3 changes: 3 additions & 0 deletions baselines/ts5.6/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11291,6 +11291,9 @@ interface Element extends Node, ARIAMixin, Animatable, ChildNode, NonDocumentTyp
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/matches)
*/
matches<K extends keyof HTMLElementTagNameMap>(selectors: K): this is HTMLElementTagNameMap[K];
matches<K extends keyof SVGElementTagNameMap>(selectors: K): this is SVGElementTagNameMap[K];
matches<K extends keyof MathMLElementTagNameMap>(selectors: K): this is MathMLElementTagNameMap[K];
matches(selectors: string): boolean;
/**
* The **`releasePointerCapture()`** method of the Element interface releases (stops) _pointer capture_ that was previously set for a specific (PointerEvent) _pointer_.
Expand Down
15 changes: 15 additions & 0 deletions src/build/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,19 @@ export function emitWebIdl(
}
}

/// Emit overloads for the matches method
function emitMatchesOverloads(m: Browser.Method) {
if (matchParamMethodSignature(m, "matches", "boolean", "string")) {
const paramName = m.signature[0].param![0].name;
for (const mapName of tagNameMapNames) {
printer.printLine(
`matches<K extends keyof ${mapName}>(${paramName}: K): this is ${mapName}[K];`,
);
}
printer.printLine(`matches(${paramName}: string): boolean;`);
}
}

/// Emit overloads for the querySelector method
function emitQuerySelectorOverloads(m: Browser.Method) {
if (
Expand Down Expand Up @@ -988,6 +1001,8 @@ export function emitWebIdl(
return emitCreateEventOverloads(m);
case "getElementsByTagName":
return emitGetElementsByTagNameOverloads(m);
case "matches":
return emitMatchesOverloads(m);
case "querySelector":
return emitQuerySelectorOverloads(m);
case "querySelectorAll":
Expand Down