matches() public method

Checks that the node matches selector.
public matches ( string $selector, boolean $strict = false ) : boolean
$selector string CSS selector
$strict boolean
return boolean
コード例 #1
0
ファイル: ElementTest.php プロジェクト: imangazaliev/didom
 public function testMatches()
 {
     $element = new Element('ul', null, ['id' => 'foo', 'class' => 'bar baz']);
     $this->assertTrue($element->matches('ul'));
     $this->assertTrue($element->matches('#foo'));
     $this->assertTrue($element->matches('.bar'));
     $this->assertTrue($element->matches('ul#foo.bar.baz'));
     $this->assertFalse($element->matches('a#foo.bar.baz'));
     // strict
     $this->assertTrue($element->matches('ul#foo.bar.baz', true));
     $this->assertFalse($element->matches('ul#foo.bar', true));
     $this->assertFalse($element->matches('ul#foo', true));
     $this->assertFalse($element->matches('ul.bar.baz', true));
     $this->assertFalse($element->matches('ul.bar.baz', true));
     $element = new Element('p');
     $this->assertTrue($element->matches('p', true));
 }