Skip to content

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

@ogolovanov

Description

@ogolovanov

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

Metadata

Metadata

Assignees

Labels

bugA confirmed bug, that we should fixfixedAn {bug|improvement} that has been {fixed|implemented}

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions