public function index($selector = NULL)
{
if (count($this->_nodes) > 0) {
if (NULL === $selector) {
return $this->xpath('count(
preceding-sibling::node()[
self::* or (self::text() and normalize-space(.) != "")
]
)', $this->_nodes[0]);
} else {
$callback = $this->getSelectorCallback($selector);
foreach ($this->_nodes as $index => $node) {
if ($callback($node)) {
return $index;
}
}
}
}
return -1;
}