QueryPath\DOMQuery::parentsUntil PHP Метод

parentsUntil() публичный Метод

If a selector is present, only matching ancestors will be retrieved.
См. также: parent()
См. также: siblings()
См. также: children()
С версии: 2.1
Автор: eabrand
public parentsUntil ( string $selector = null )
$selector string A valid CSS 3 Selector.
    public function parentsUntil($selector = null)
    {
        $found = new \SplObjectStorage();
        foreach ($this->matches as $m) {
            while ($m->parentNode->nodeType !== XML_DOCUMENT_NODE) {
                $m = $m->parentNode;
                // Is there any case where parent node is not an element?
                if ($m->nodeType === XML_ELEMENT_NODE) {
                    if (!empty($selector)) {
                        if (QueryPath::with($m, null, $this->options)->is($selector) > 0) {
                            break;
                        } else {
                            $found->attach($m);
                        }
                    } else {
                        $found->attach($m);
                    }
                }
            }
        }
        return $this->inst($found, null, $this->options);
    }