Skip to content

Commit 5139c77

Browse files
committed
fix for not(), it should pass all nodes on no match
1 parent dd17eae commit 5139c77

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/Rct567/DomQuery/DomQuery.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,8 @@ public function not($selector)
564564
$result->addDomNode($node);
565565
}
566566
}
567+
} else {
568+
$result->addNodes($this->nodes);
567569
}
568570
}
569571
}

tests/Rct567/DomQuery/Tests/DomQueryTraversingFilterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function testNot()
6262
$dom = new DomQuery('<a>hai</a> <a></a> <a id="mmm"></a> <a class="x"></a> <a class="xpp"></a>');
6363
$selection = $dom->find('a');
6464
$this->assertEquals(5, $selection->length);
65+
$this->assertEquals(5, $selection->not('p')->length);
6566
$this->assertEquals(0, $selection->not('a')->length);
6667
$this->assertEquals(4, $selection->not('#mmm')->length);
6768
$this->assertEquals(3, $selection->not('#mmm')->not('.xpp')->length);

0 commit comments

Comments
 (0)