Repository navigation
Return one node per match from firstChild() - #109
Merged
Merged
Conversation
firstChild() broke out of its outer loop after the first match that had a child element, so it returned at most one node. It now returns one per match, like lastChild(). 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 @@
## main #109 +/- ##
============================================
+ Coverage 90.69% 90.79% +0.10%
+ Complexity 1424 1423 -1
============================================
Files 25 25
Lines 3170 3163 -7
============================================
- Hits 2875 2872 -3
+ Misses 295 291 -4 ☔ 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.
firstChild()broke out of its outer loop as soon as one match had a child element, so it returned at most one node for the whole match set.lastChild()returns one node per match.Behaviour change:
firstChild()now returns the first child element of every match. To get the old result, usefirstChild()->first().Changes
$flagand the outerbreakinQueryFilters::firstChild(), and remove a stale commentfirstChild()andlastChild()DocBlocks to say they return one child element per matchTests
testFirstChildReturnsOneChildPerMatchmatches four elements: one empty, one with only text, one with text before its child elements, and one with a comment before its child element. It fails onmain(it gets'a') and passes with this change. phpunit,lintandlint:min-phpall pass.Fixes #78.
🤖 Generated with Claude Code