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
not() keeps the excluded nodes instead of removing them when given an SplObjectStorage #75
not() is documented as removing the matching elements. When the argument is an SplObjectStorage it does the exact opposite: it keeps only the nodes in the storage and discards everything else, turning the negation into an intersection.
The other three accepted argument types (CSS selector, DOMElement, array of DOMNodes) all behave correctly, so the bug is confined to one branch.
Root cause
src/Helpers/QueryFilters.php:719-723 — the condition is missing its negation:
} elseif ($selectorinstanceof SplObjectStorage) {
foreach ($this->matchesas$m) {
if ($selector->offsetExists($m)) { // <-- should be ! $selector->offsetExists($m)$found->offsetSet($m);
}
}
}
Compare the array branch directly above it, which has the negation the storage branch lacks:
Node identity is per-document, so both sides must come from the sameDOMDocument or nothing matches either way and the bug is masked. The snippet below uses branch() to guarantee that.
Workaround
Pass $other->get() (array) rather than $other->get(null, true) (SplObjectStorage).
Activity