public function not($selector = null)
{
if (is_string($selector)) {
phpQuery::debug(array('not', $selector));
} else {
phpQuery::debug('not');
}
$stack = array();
if ($selector instanceof self || $selector instanceof DOMNODE) {
foreach ($this->stack() as $node) {
if ($selector instanceof self) {
$matchFound = false;
foreach ($selector->stack() as $notNode) {
if ($notNode->isSameNode($node)) {
$matchFound = true;
}
}
if (!$matchFound) {
$stack[] = $node;
}
} elseif ($selector instanceof DOMNODE) {
if (!$selector->isSameNode($node)) {
$stack[] = $node;
}
} else {
if (!$this->is($selector)) {
$stack[] = $node;
}
}
}
} else {
$orgStack = $this->stack();
$matched = $this->filter($selector, true)->stack();
// $matched = array();
// // simulate OR in filter() instead of AND 5y
// foreach($this->parseSelector($selector) as $s) {
// $matched = array_merge($matched,
// $this->filter(array($s))->stack()
// );
// }
foreach ($orgStack as $node) {
if (!$this->elementsContainsNode($node, $matched)) {
$stack[] = $node;
}
}
}
return $this->newInstance($stack);
}