protected function initialMatchOnElementNS($selector, $matches)
{
$ns = $selector->ns;
$elements = $this->initialMatchOnElement($selector, $matches);
// "any namespace" matches anything.
if ($ns == '*') {
return $elements;
}
// Loop through and make a list of items that need to be filtered
// out, then filter them. This is required b/c ObjectStorage iterates
// wrongly when an item is detached in an access loop.
$detach = array();
foreach ($elements as $node) {
// This lookup must be done PER NODE.
$nsuri = $node->lookupNamespaceURI($ns);
if (empty($nsuri) || $node->namespaceURI != $nsuri) {
$detach[] = $node;
}
}
foreach ($detach as $rem) {
$elements->detach($rem);
}
$selector->ns = null;
return $elements;
}