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

querySelector pseudo class :has not working #1373

Closed
guenichone opened this issue Mar 27, 2024 · 4 comments · Fixed by #1521
Closed

querySelector pseudo class :has not working #1373

guenichone opened this issue Mar 27, 2024 · 4 comments · Fixed by #1521
Assignees
Labels
bug Something isn't working

Comments

@guenichone
Copy link

Describe the bug
:has pseudo selector in query does not seem to be supported.

w3c spec: https://www.w3.org/TR/selectors-4/#has-pseudo

working sample: https://try.jsoup.org/ with query : p:has(a[href*=jsoup])

To Reproduce
Steps to reproduce the behavior:

Create a test with

const {container} = render(<html>
            <head>
                <title>Try jsoup</title>
            </head>
            <body>
            <p>This is <a href="https://jsoup.org/">jsoup</a>.</p>
            </body>
            </html>
        );

const result1 = container.querySelector('a') // this is not null
const result2 = container.querySelector('p:has(a[href*=jsoup])') // this is null where it should not

image

Expected behavior
result should give me back the

element in the
image

Device:

@guenichone guenichone added the bug Something isn't working label Mar 27, 2024
@timche
Copy link

timche commented Aug 2, 2024

Were you able to find any solution for this? Running into the same problem.

@guenichone
Copy link
Author

Were you able to find any solution for this? Running into the same problem.

Unfortunately not :(

@timche
Copy link

timche commented Aug 29, 2024

Were you able to find any solution for this? Running into the same problem.

Unfortunately not :(

Too bad it's not getting any attention, because this library is great. I've switched to https://github.com/WebReflection/linkedom since then, which has support.

@capricorn86
Copy link
Owner

Thank you for reporting @guenichone and @timche! 🙂

Happy DOM now has support for the :has pseudo selector.

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.

3 participants