Skip to content
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

Fixes queryAssignedNodes when querying for nodes on browsers that do … #1092

Merged
merged 6 commits into from
Oct 20, 2020

Conversation

sorvell
Copy link
Member

@sorvell sorvell commented Oct 16, 2020

…have Element.matches

Fixes #1088.

@@ -465,9 +465,10 @@ export function queryAssignedNodes(
if (nodes && selector) {
nodes = nodes.filter(
(node) => node.nodeType === Node.ELEMENT_NODE &&
(node as Element).matches ?
// tslint:disable-next-line:no-any testing existence on older browsers
((node as any).matches ?
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the DOM types include .matches you shouldn't need the as any cast. Did the old code not type-check?

(node as Element).matches(selector) :
legacyMatches.call(node as Element, selector));
// tslint:disable-next-line:no-any testing existence on older browsers
((node as any).matches ?
Copy link
Contributor

Choose a reason for hiding this comment

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

Still curious about this cast here. Why is it necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

TypeScript complains that the check is unnecessary becausematches always exists. The previous code probably didn't analyze path.

@sorvell sorvell merged commit db153a5 into master Oct 20, 2020
@sorvell sorvell deleted the fix-queryAssignedNodes branch October 20, 2020 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Illegal invocation error is thrown when using queryAssignedNodes with text nodes
3 participants