capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.14k stars 189 forks source link

querySelector pseudo class :has not working #1373

Open guenichone opened 4 months ago

guenichone commented 4 months ago

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: