diff options
author | Rowan Tommins <[email protected]> | 2020-06-24 13:01:34 +0100 |
---|---|---|
committer | Rowan Tommins <[email protected]> | 2020-06-24 13:01:34 +0100 |
commit | 8696866ef2578952ff6d8fbea2d7a12372a47ea6 (patch) | |
tree | 653c135519115c2cad2a4561b64c1b11401fd5e3 /test | |
parent | a3edfe52f9e7380e498d33157e1330e85386645d (diff) |
Add special case for end tag </br>. Fixes #185
Normally, an end tag for a void element would simply be discarded,
but the spec includes a special rule as follows:
> An end tag whose tag name is "br"
> Parse error. Drop the attributes from the token, and act as
> described in the next entry; i.e. act as if this was a "br"
> start tag token with no attributes, rather than the end tag
> token that it actually is.
Diffstat (limited to 'test')
-rw-r--r-- | test/HTML5/Parser/DOMTreeBuilderTest.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index 00e9a47..af79fda 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -715,4 +715,29 @@ EOM; $this->assertSame('p', $audio->parentNode->nodeName); $this->assertSame(3, $audio->childNodes->length); } + + public function testClosingBr() + { + $html = <<<EOM +<!DOCTYPE html> +<html> + <head> + <title>testClosingBr</title> + </head> + <body> + <p> + This line ends with a normal line break <br class="attribute-should-be-retained"> + This line ends with a line break marked up as a closing tag </br class="attribute-should-be-discarded"> + </p> + </body> +</html>> +</html> +EOM; + + $dom = $this->parse($html); + + $this->assertSame(2, $dom->getElementsByTagName('br')->length); + $this->assertSame(1, $dom->getElementsByTagName('br')->item(0)->attributes->length); + $this->assertSame(0, $dom->getElementsByTagName('br')->item(1)->attributes->length); + } } |