QueryPath\CSS\DOMTraverser::initialMatchOnElement PHP Method

initialMatchOnElement() protected method

Shortcut for setting the initial match.
protected initialMatchOnElement ( $selector, $matches )
    protected function initialMatchOnElement($selector, $matches)
    {
        $element = $selector->element;
        if (is_null($element)) {
            $element = '*';
        }
        $found = $this->newMatches();
        foreach ($matches as $node) {
            // Capture the case where the initial element is the root element.
            if ($node->tagName == $element || $element == '*' && $node->parentNode instanceof \DOMDocument) {
                $found->attach($node);
            }
            $nl = $node->getElementsByTagName($element);
            $this->attachNodeList($nl, $found);
        }
        $selector->element = null;
        return $found;
    }