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

nested :has() selector not working [v1.17.2] #2131

Open
ogolovanov opened this issue Mar 14, 2024 · 0 comments
Open

nested :has() selector not working [v1.17.2] #2131

ogolovanov opened this issue Mar 14, 2024 · 0 comments

Comments

@ogolovanov
Copy link

ogolovanov commented Mar 14, 2024

Hi.

It seems nested :has() selectors not working.

String html =
    "<html>" +
        "<head></head>" +
        "<body>" +
            "<div>" +
                "<div><span>hello</span></div>" +
                "<div><span>world</span></div>" +
            "</div>" +
        "</body></html>";
Document document = Jsoup.parse(html);

System.out.println(document.select("div:has(> div:has(> span) + div:has(> span))").size());
System.out.println(document.select("div:has(> span) + div:has(> span)").stream().filter(v -> v.parent().is("div")).count());

Result:

0 // = unexpected
1 // = as expected

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

No branches or pull requests

1 participant