You are here

protected function QueryPathCssEventHandler::firstOfType in QueryPath 6

Same name and namespace in other branches
  1. 7.3 QueryPath/CssEventHandler.php \QueryPathCssEventHandler::firstOfType()
  2. 7.2 QueryPath/CssEventHandler.php \QueryPathCssEventHandler::firstOfType()
1 call to QueryPathCssEventHandler::firstOfType()
QueryPathCssEventHandler::pseudoClass in QueryPath/CssEventHandler.php

File

QueryPath/CssEventHandler.php, line 807

Class

QueryPathCssEventHandler

Code

protected function firstOfType() {
  $matches = $this
    ->candidateList();
  $found = new SplObjectStorage();
  foreach ($matches as $item) {
    $type = $item->tagName;
    $parent = $item->parentNode;
    foreach ($parent->childNodes as $kid) {
      if ($kid->nodeType == XML_ELEMENT_NODE && $kid->tagName == $type) {
        if (!$found
          ->contains($kid)) {
          $found
            ->attach($kid);
        }
        break;
      }
    }
  }
  $this->matches = $found;
}