You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consolidate the sibling and ancestor traversal loops in QueryFilters into one helper #115
Follow-up from the /simplify pass on #72. Assumes #72 is merged.
Problem
The sibling and ancestor traversals in src/Helpers/QueryFilters.php are each a hand-written copy of the same loop, differing only in the DOM property they walk and whether they stop at the first match:
Methods
Axis
Shape
nextAll() / prevAll()
nextSibling / previousSibling
collect, then filter the set
next() / prev()
nextSibling / previousSibling
stop at first match
nextUntil() / prevUntil()
nextSibling / previousSibling
collect until a match
parents() / parent() / parentsUntil()
parentNode
all three shapes
siblings()
both
collect, then filter
#72 had to make the same edit in every one of them, which is the cost of this layout: a fix to one is easily missed in its mirror.
Proposal
One private helper that walks an axis and applies the shape, e.g.
The public methods become one-line calls. PHP 7.1 compatible ($m->{$axis}).
This should be a pure refactor: the existing tests (including Issue62Test) must pass unchanged. Ordering is tracked separately in the jQuery-ordering issue.
Activity
Walk sibling and ancestor axes through one helper