Skip to content

fix querySelector method #170

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 5 commits into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from 4 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: 2 additions & 1 deletion TS.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -807,12 +807,13 @@ module Emit =
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(selectors: string): Element | 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<E extends Element>(selectors: string): NodeListOf<E>;"
Pt.Printl "querySelectorAll(selectors: string): NodeListOf<Element>;"

let EmitHTMLElementTagNameMap () =
Expand Down
3 changes: 2 additions & 1 deletion baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13736,8 +13736,9 @@ interface NavigatorUserMedia {

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we combine these, too?

querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

querySelectorAll(selectors: string): NodeListOf<Element>;
}

Expand Down