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

Element.matches producing false positives when using descendant combinators #614

Closed
IGx89 opened this issue Oct 12, 2022 · 4 comments · Fixed by #615
Closed

Element.matches producing false positives when using descendant combinators #614

IGx89 opened this issue Oct 12, 2022 · 4 comments · Fixed by #615
Labels
bug Something isn't working

Comments

@IGx89
Copy link
Contributor

IGx89 commented Oct 12, 2022

Describe the bug
When using a descendant combinator (" ") with Element.matches, if the rightmost selector matches it always returns true regardless of the other selectors.

I ran into this bug when using vue-test-utils's Wrapper.findAll, which under the scenes uses Element.matches.

To Reproduce
Given the following HTML:

<div class="red">
   <div>
      <div class="active"></div>
   </div>
</div>

The following two statements, running on the innermost div (the one with class="active") both return true even though the second should return false:

element.matches('div.red div.active');
element.matches('div.green div.active');

Expected behavior
Invalid matches should always return false.

Device:

  • OS: Windows
  • Browser: happy-dom
  • Version: latest
@IGx89 IGx89 added the bug Something isn't working label Oct 12, 2022
@IGx89 IGx89 changed the title Element.matches producing false positives when using descendent combinators Element.matches producing false positives when using descendant combinators Oct 12, 2022
IGx89 added a commit to IGx89/happy-dom that referenced this issue Oct 12, 2022
@capricorn86
Copy link
Owner

Thanks for reporting @IGx89! 🙂

Just to confirm, by latest you mean v7.5.7? I made a fix for Element.matches() in v7.5.0.

@IGx89
Copy link
Contributor Author

IGx89 commented Oct 12, 2022

Yep! I have a PR coming shortly actually, would be here already but the pre-commit hooks take quite a while to complete on my machine :p.

@capricorn86
Copy link
Owner

Nice ⭐

capricorn86 added a commit that referenced this issue Oct 12, 2022
#614@patch: Element.matches not working properly with descendant combinators.
@capricorn86
Copy link
Owner

Thanks again for you contribution!

it has been released:
https://github.com/capricorn86/happy-dom/releases/tag/v7.5.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants