Repository navigation
Count and keep every node in even(), odd(), first() and last() - #158
Open
gravitypdf-bot wants to merge 5 commits into
Open
gravitypdf-bot wants to merge 5 commits into
gravitypdf-bot wants to merge 5 commits into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #143 and #146. Stacked on #150; merge that first.
even(),odd(),first()andlast()now count and keep every node in the set, including text, comment, CDATA and processing-instruction nodes, as jQuery does:contents()->odd()can no longer come back empty.first()is noweq(0), so the two always agree.last()iseq(count() - 1), so it works whether or noteq(),get()andslice()ignore negative indexes;slice(-2)returns the whole set #142 (negative indexes) has merged.Code that relied on skipping text nodes can use
children()->first()orfilter('*')->first(), and likewise forlast(),even()andodd().Tests
tests/Issues/Issue143Test.phpcovers both issues' tables against jQuery 3.7.1.DOMQueryTest::testFirstAndLastWithNonElementNodesnow expects the first and last nodes, and checks thefilter('*')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