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
Positional selectors in prevAll(), parents() and the *Until() methods count in document order, not jQuery's walk order #134
QueryPath counts a positional pseudo-class (:first, :last, :eq(), …) in a traversal's selector in document order. jQuery filters the walk's results in walk order, before sorting them, so the two disagree for the backwards traversals:
$xml = '<?xml version="1.0"?><r><a id="a"/><b id="b"/><c id="c"/><d id="d"/><e id="e"/></r>';
qp($xml, '#e')->prevAll(':first'); // QueryPath: a jQuery: d (the nearest)qp($xml, '#e')->prevAll(':last'); // QueryPath: d jQuery: aqp($xml, '#e')->prevAll(':eq(0)'); // QueryPath: a jQuery: d
parents(':first'), parentsUntil() and prevUntil() differ the same way, on single and multi-element sets.
Cause
The positional filter runs inside DOMTraverser on its result set, which is in document order (#66), independently of the order the traversal method returns. #130 (#117) puts the returned results in jQuery's order and #131 (#118) pins the current positional results, both noting this as the remaining difference.
Proposal
Let callers that filter a walk pass the candidate order through to the positional filter (for example as part of DOMTraverser::filterNodes() from #128, which already preserves input order), and have the reverse-direction traversals filter in walk order. This is a behaviour change.
Activity