Skip to content

Count even() and odd() from zero, as jQuery and :even/:odd do - #150

Open
gravitypdf-bot wants to merge 3 commits into
mainfrom
fix/issue-145
Open

gravitypdf-bot wants to merge 3 commits into
mainfrom
fix/issue-145

Conversation

@gravitypdf-bot

Copy link
Copy Markdown
Contributor

Fixes #145. Breaking change.

even() now keeps positions 0, 2, 4, … and odd() keeps 1, 3, 5, …, as jQuery's .even()/.odd() and QueryPath's own :even/:odd do. Both methods now go through Util::applyPositionalPseudoClass(), the code behind the pseudo-classes, so the methods and the pseudo-classes can't drift apart again. To keep the previous results, swap the calls.

How text nodes are counted is unchanged here. The fix for #143 changes that, in a PR stacked on this one.

Tests

  • tests/Issues/Issue145Test.php covers the issue's table and checks that both methods agree with filter(':even')/filter(':odd').
  • DOMQueryTest::testEven/testOdd have their li counts swapped.

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 3 commits October 26, 2026 17:17
even() kept positions 1, 3, 5 and odd() kept 0, 2, 4, the reverse of
jQuery's .even() and .odd() and of QueryPath's own :even and :odd
pseudo-classes. Both now go through one helper.

Fixes #145.

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.21%. Comparing base (6ae6acf) to head (346ec28).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #150      +/-   ##
============================================
+ Coverage     90.69%   91.21%   +0.52%     
- Complexity     1424     1436      +12     
============================================
  Files            25       26       +1     
  Lines          3170     3177       +7     
============================================
+ Hits           2875     2898      +23     
+ 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.

even() and odd() are swapped relative to jQuery and the :even/:odd pseudo-classes

1 participant