Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Imangazaliev committed Oct 14, 2016
1 parent e57fe9b commit b766098
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/DiDom/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ public function innerHtml($options = LIBXML_NOEMPTYTAG)
* Sets inner HTML.
*
* @param string $html
*
* @return Element
*/
public function setInnerHtml($html)
{
Expand Down Expand Up @@ -292,6 +294,8 @@ public function setInnerHtml($html)

Errors::restore();
}

return $this;
}

/**
Expand Down
15 changes: 15 additions & 0 deletions tests/DiDom/ElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,21 @@ public function testInnerHtml()
$this->assertTrue(is_string($document->find('body')[0]->innerHtml()));
}

public function testSetInnerHtml()
{
$list = new Element('ul');

$html = '<li>One</li><li>Two</li><li>Three</li>';

$this->assertEquals($list, $list->setInnerHtml($html));
$this->assertEquals(['One', 'Two', 'Three'], $list->find('li::text'));

$span = new Element('span');

$this->assertEquals($span, $span->setInnerHtml(' Foo '));
$this->assertEquals('<span> Foo </span>', $span->html());
}

public function testHtmlWithOptions()
{
$html = '<html><body><span></span></body></html>';
Expand Down

0 comments on commit b766098

Please sign in to comment.