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

Conversation

YuichiNukiyama
Copy link
Contributor

fixes #12568

@mhegazy
Copy link
Contributor

mhegazy commented May 12, 2017

sorry for the delay. can you refresh the PR?

@YuichiNukiyama
Copy link
Contributor Author

done.

@@ -13736,8 +13736,10 @@ interface NavigatorUserMedia {

interface NodeSelector {
querySelector<K extends keyof ElementTagNameMap>(selectors: K): ElementTagNameMap[K] | null;
querySelector<E extends Element>(selectors: string): E | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

why not combine both signatures as:

querySelector<E extends Element = Element>(selectors: string): E | null;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not know generic default... I fix it 😃

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!

@AustinMatherne
Copy link

@mhegazy anything holding this PR up? This makes testing the DOM much nicer in Angular 2.

@mhegazy mhegazy merged commit 7cc695c into microsoft:master Aug 15, 2017
@YuichiNukiyama YuichiNukiyama deleted the fix_queryselector branch August 15, 2017 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

querySelector and querySelectorAll should support generics for "string" selectors
4 participants