You are here

protected function QueryPathCssEventHandler::lastOfType in QueryPath 7.2

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

File

QueryPath/CssEventHandler.php, line 826

Class

QueryPathCssEventHandler

Code

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