Skip to content

Count and keep every node in even(), odd(), first() and last() - #158

Open
gravitypdf-bot wants to merge 5 commits into
fix/issue-145from
fix/issue-143
Open

gravitypdf-bot wants to merge 5 commits into
fix/issue-145from
fix/issue-143

Conversation

@gravitypdf-bot

Copy link
Copy Markdown
Contributor

Fixes #143 and #146. Stacked on #150; merge that first.

even(), odd(), first() and last() now count and keep every node in the set, including text, comment, CDATA and processing-instruction nodes, as jQuery does:

Code that relied on skipping text nodes can use children()->first() or filter('*')->first(), and likewise for last(), even() and odd().

Tests

  • tests/Issues/Issue143Test.php covers both issues' tables against jQuery 3.7.1.
  • DOMQueryTest::testFirstAndLastWithNonElementNodes now expects the first and last nodes, and checks the filter('*') alternatives.

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:24
even() and odd() counted text, comment, CDATA and processing-instruction
nodes but dropped them from the result, so contents()->odd() could be
empty. first() and last() skipped them altogether, so first() disagreed
with eq(0). As in jQuery, all four now treat every node in the set
alike, and first() and last() are eq(0) and eq(-1).

Fixes #143.
Fixes #146.

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

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 (346ec28) to head (73d64cc).

Additional details and impacted files
@@               Coverage Diff                @@
##             fix/issue-145     #158   +/-   ##
================================================
  Coverage            91.21%   91.21%           
+ Complexity            1436     1432    -4     
================================================
  Files                   26       26           
  Lines                 3177     3166   -11     
================================================
- Hits                  2898     2888   -10     
+ Misses                 279      278    -1     

☔ 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.

1 participant