Skip to content

Commit

Permalink
Merge pull request #168 from idimopoulos/html5_encoding
Browse files Browse the repository at this point in the history
Set default encoding in the DOMDocument object
  • Loading branch information
goetas authored Jun 15, 2019
2 parents c24cd7e + 5f71e6c commit ad8802c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/HTML5/Parser/DOMTreeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public function __construct($isFragment = false, array $options = array())
$dt = $impl->createDocumentType('html');
// $this->doc = \DOMImplementation::createDocument(NULL, 'html', $dt);
$this->doc = $impl->createDocument(null, null, $dt);
$this->doc->encoding = !empty($options['encoding']) ? $options['encoding'] : 'UTF-8';
}

$this->errors = array();
Expand Down
1 change: 1 addition & 0 deletions test/HTML5/Parser/DOMTreeBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function testDocument()
$html = '<!DOCTYPE html><html></html>';
$doc = $this->parse($html);

$this->assertEquals('UTF-8', $doc->encoding);
$this->assertInstanceOf('\DOMDocument', $doc);
$this->assertEquals('html', $doc->documentElement->tagName);
$this->assertEquals('http://www.w3.org/1999/xhtml', $doc->documentElement->namespaceURI);
Expand Down

0 comments on commit ad8802c

Please sign in to comment.