Skip to content

Add generic support to Element.closest() #697

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 3 commits into from
Jun 4, 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
2 changes: 1 addition & 1 deletion baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5018,7 +5018,7 @@ interface Element extends Node, ParentNode, NonDocumentTypeChildNode, ChildNode,
*/
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;
closest<E extends Element = Element>(selector: string): E | null;
/**
* Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise.
*/
Expand Down
2 changes: 1 addition & 1 deletion inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@
"override-signatures": [
"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"
"closest<E extends Element = Element>(selector: string): E | null"
]
},
"insertAdjacentElement": {
Expand Down
2 changes: 1 addition & 1 deletion src/widlprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function convertOperation(operation: webidl2.OperationMemberType, inheritedExpos
throw new Error("Unexpected anonymous operation");
}
return {
name: operation.name,
name: operation.name || undefined,
signature: [{
...convertIdlType(operation.idlType),
param: operation.arguments.map(convertArgument)
Expand Down