lastChild() public method

public lastChild ( ) : Element | null
return Element | null
示例#1
0
 public function testLastChild()
 {
     $html = '<ul><li>One</li><li>Two</li><li>Three</li></ul>';
     $document = new Document($html, false);
     $list = $document->first('ul');
     $this->assertEquals($list->getNode()->lastChild, $list->lastChild()->getNode());
     $list = new Element('ul');
     $this->assertNull($list->lastChild());
     // with text nodes
     $html = '<p>Foo <span>Bar</span> Baz</p>';
     $document = new Document($html, false);
     $paragraph = $document->first('p');
     $lastChild = $paragraph->getNode()->lastChild;
     $this->assertEquals($lastChild, $paragraph->lastChild()->getNode());
 }