Skip to content

Commit 2ce9af8

Browse files
committed
Use the named_partial selector in DocumentElement::hasContent()
1 parent 9b08f62 commit 2ce9af8

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/Element/DocumentElement.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public function getContent()
4646
*/
4747
public function hasContent(string $content)
4848
{
49-
return $this->has('named', array('content', $content));
49+
// anything matched by the "named_exact" selector is also matched by "named_partial",
50+
// so checking "named_partial" directly gives the same result as "named" while
51+
// saving the extra driver query the exact-then-partial fallback would make
52+
return $this->has('named_partial', array('content', $content));
5053
}
5154
}

tests/Element/DocumentElementTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ public function testHasContent()
164164
$this->elementFinder->expects($this->exactly(2))
165165
->method('findAll')
166166
->willReturnMap(array(
167-
array('named', array('content', 'some content'), '//html', array($node1, $node2)),
168-
array('named', array('content', 'some other content'), '//html', array()),
167+
array('named_partial', array('content', 'some content'), '//html', array($node1, $node2)),
168+
array('named_partial', array('content', 'some other content'), '//html', array()),
169169
));
170170

171171
$this->assertTrue($this->document->hasContent('some content'));

0 commit comments

Comments
 (0)