Skip to content

Unexpected select() behavior in version 1.17.1 #2073

@rzam

Description

@rzam

There seems to be some weird behavior in version 1.17.1 when combining multiple nested attribute selectors.

Minimal working example:

Document document = Jsoup.parse("""
    <div id="parent">
        <span class="child"></span>
        <span class="child"></span>
        <span class="child"></span>
    </div>
""");

System.out.println(document.select("[class*=\"child\"]").size()); // 3
System.out.println(document.select("#parent [class*=\"child\"]").size()); // 3
System.out.println(document.select("#parent [class*=\"child\"], .some-other-selector").size()); // 3
System.out.println(document.select("#parent [class*=\"child\"], .some-other-selector .nested").size()); // 0

The first three selects all correctly find 3 nodes, while the last one doesn't seem to find anything.

The code above works correctly (all four selects find 3 nodes) on version 1.16.2.

Tested on OpenJDK 11, 17 and 21.

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