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
:scope always refers to the document element, so find(':scope > li') matches nothing #133
:scope always refers to the document element, never to the element find() was called on. So it can't be used to anchor a search at the current match set, as jQuery's $(el).find(':scope > li') does:
$xml = '<?xml version="1.0"?><root><ul id="u1"><li id="a"/><li id="b"/></ul><ul id="u2"><li id="c"/></ul></root>';
qp($xml, '#u1')->find(':scope > li'); // (none), expected a, bqp($xml, 'ul')->find(':scope > li'); // (none), expected a, b, cqp($xml, '#u1')->find('li:not(:scope > li)'); // a, b, expected (none)qp($xml, '#u1')->find('li:matches(:scope > li)'); // (none), expected a, bqp($xml)->find(':scope > ul'); // u1, u2 (correct only because the scope is the root)
Cause
DOMQuery::find() / findInPlace() and DOM's constructor build new DOMTraverser($this->matches) without a scope node, so DOMTraverser falls back to $this->dom->documentElement. The nested traversers for :not() / :matches() (PseudoClass::is()) also pass null, so :scope inside them is the document element even when the outer query had a real scope. Noted in #128.
With more than one element in the set, :scope should match each of them (jQuery runs .find() per element).
Activity