Skip to content

Commit 585278e

Browse files
committed
split test
1 parent 4d14e8c commit 585278e

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/HTML5/Parser/DOMTreeBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ public function text($data)
567567
// Per '8.2.5.4.3 The "before head" insertion mode' the characters
568568
// " \t\n\r\f" should be ignored .
569569
$dataTmp = trim($data, " \t\n\r\f");
570-
if (! empty($dataTmp)) {
570+
if (!empty($dataTmp)) {
571571
$this->startTag('head');
572572
$this->endTag('head');
573573
$this->startTag('body');

test/HTML5/Html5Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ public function testTagOmission($input, $expected)
507507

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

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

513513
/**
@@ -534,7 +534,7 @@ public function tagOmissionProvider()
534534
'<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
535535
<body>
536536
<br>
537-
</body>'
537+
</body>',
538538
),
539539
);
540540
}

test/HTML5/Parser/DOMTreeBuilderTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,17 @@ public function testText()
457457
$data = $wrapper->childNodes->item(0);
458458
$this->assertEquals(XML_TEXT_NODE, $data->nodeType);
459459
$this->assertEquals('test', $data->data);
460+
}
460461

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

470473
public function testParseErrors()

0 commit comments

Comments
 (0)