Repository navigation
fix(traversing): return prevAll/prevUntil results in reverse document order - #5677
Enesuygurs wants to merge 1 commit into
Conversation
… order
prevAll and prevUntil only removed duplicates when called on more than
one element, so the result was each starting element's siblings
concatenated, e.g. `$('#c, #d').prevAll()` gave `b, a, c`.
jQuery sorts these results and then reverses them (closest sibling
first), as cheerio already does for parents and parentsUntil. Use the
same post-processing for prevAll and prevUntil.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge.
|
Fixes #5676
When
.prevAll()or.prevUntil()is called on more than one element, the results were only de-duplicated, not ordered. They ended up in neither document order nor reverse document order:For
parents*andprev*, jQuery sorts the results of a multi-element selection and then reverses them ("in order beginning with the closest sibling"). Cheerio already does this forparentsandparentsUntil. This PR applies the same post-processing toprevAllandprevUntil. Single-element calls are unaffected and skip the sort.The existing
prevUntiltest "(function) : should reset the index for each starting element" asserted the old order (orange, carrot). It now expectscarrot, orange, which is what jQuery returns for the same selection. The index-reset behaviour it covers is unchanged.Tests: added ordering tests for
prevAll(same parent and different parents) andprevUntil. They fail onmainand pass with the change. I checked the outputs against jQuery 4.0.0 on jsdom.npm run test:vipasses (838 tests), as donpm run lint:tsandnpm run lint:biome.