Skip to content

Count a positional compound left of a combinator across the document in filter() - #151

Open
gravitypdf-bot wants to merge 5 commits into
mainfrom
fix/issue-132
Open

gravitypdf-bot wants to merge 5 commits into
mainfrom
fix/issue-132

Conversation

@gravitypdf-bot

Copy link
Copy Markdown
Contributor

Fixes #132.

filter(), not() and is() matched nothing for a selector like ul:first > li, where a positional pseudo-class sits on a compound left of a combinator. When the nodes in hand are tested as themselves, DOMTraverser searched below the candidates for that compound instead of across the document. It now starts that search from the document element, as find() does, so qp($xml, 'li')->filter('ul:first > li') returns the items of the first <ul>. A positional pseudo-class on the subject still counts within the set.

DOMTraverser::documentScope() is a new static helper, and NodeMatcher now uses it too, instead of building the same scope itself.

Tests

tests/Issues/Issue132Test.php compares filter() with find() over a set of selectors, and covers is(), not() and a compound whose <ul> is not in the set.

Every PR in this set adds its CHANGELOG line at the end of # Unreleased changes, so each one after the first needs a one-line conflict resolved there.

🤖 Generated with Claude Code

gravitypdf-bot and others added 5 commits October 26, 2026 17:18
…in filter()

In filterNodes(), a non-subject compound carrying a positional
pseudo-class was resolved by searching the candidates' descendants, so
filter('ul:first > li') and is('ul:first > li') matched nothing. It is
now resolved from the document element, as jQuery's .filter() does.

Fixes #132.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.25%. Comparing base (6ae6acf) to head (ef8723b).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #151      +/-   ##
============================================
+ Coverage     90.69%   91.25%   +0.55%     
- Complexity     1424     1444      +20     
============================================
  Files            25       26       +1     
  Lines          3170     3189      +19     
============================================
+ Hits           2875     2910      +35     
+ Misses          295      279      -16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

filter() and is() match nothing for a positional pseudo-class left of a combinator (ul:first > li)

1 participant