Skip to content

Commit

Permalink
split test
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Jan 11, 2023
1 parent 4d14e8c commit 585278e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/HTML5/Parser/DOMTreeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ public function text($data)
// Per '8.2.5.4.3 The "before head" insertion mode' the characters
// " \t\n\r\f" should be ignored .
$dataTmp = trim($data, " \t\n\r\f");
if (! empty($dataTmp)) {
if (!empty($dataTmp)) {
$this->startTag('head');
$this->endTag('head');
$this->startTag('body');
Expand Down
4 changes: 2 additions & 2 deletions test/HTML5/Html5Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ public function testTagOmission($input, $expected)

$out = $this->html5->saveHTML($doc);

$this->assertRegExp("|" . preg_quote($expected, "|") . "|", $out);
$this->assertRegExp('|' . preg_quote($expected, '|') . '|', $out);
}

/**
Expand All @@ -534,7 +534,7 @@ public function tagOmissionProvider()
'<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<br>
</body>'
</body>',
),
);
}
Expand Down
9 changes: 6 additions & 3 deletions test/HTML5/Parser/DOMTreeBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,17 @@ public function testText()
$data = $wrapper->childNodes->item(0);
$this->assertEquals(XML_TEXT_NODE, $data->nodeType);
$this->assertEquals('test', $data->data);
}

public function testTextBeforeHeadNotAllowed()
{
// The DomTreeBuilder has special handling for text when in before head mode.
$html = '<!DOCTYPE html><html>
Foo<head></head><body></body></html>';
$html = '<!DOCTYPE html><html>Foo<head></head><body></body></html>';
$doc = $this->parse($html);
$this->assertEquals('Line 0, Col 0: Unexpected text. Ignoring: Foo', $this->errors[0]);
$this->assertEquals('Line 0, Col 0: Unexpected head tag outside of head context.', $this->errors[0]);
$headElement = $doc->documentElement->firstChild;
$this->assertEquals('head', $headElement->tagName);
$this->assertXmlStringEqualsXmlString($doc, '<html xmlns="http://www.w3.org/1999/xhtml"><head/><body>Foo<head/><body/></body></html>');
}

public function testParseErrors()
Expand Down

0 comments on commit 585278e

Please sign in to comment.