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 /src/HTML5 | |
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 'src/HTML5')
-rw-r--r-- | src/HTML5/Parser/DOMTreeBuilder.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/HTML5/Parser/DOMTreeBuilder.php b/src/HTML5/Parser/DOMTreeBuilder.php index e9bca4e..448dec7 100644 --- a/src/HTML5/Parser/DOMTreeBuilder.php +++ b/src/HTML5/Parser/DOMTreeBuilder.php @@ -474,8 +474,14 @@ class DOMTreeBuilder implements EventHandler { $lname = $this->normalizeTagName($name); - // Ignore closing tags for unary elements. - if (Elements::isA($name, Elements::VOID_TAG)) { + // Special case within 12.2.6.4.7: An end tag whose tag name is "br" should be treated as an opening tag + if ($name === 'br') { + $this->parseError('Closing tag encountered for void element br.'); + + $this->startTag('br'); + } + // Ignore closing tags for other unary elements. + elseif (Elements::isA($name, Elements::VOID_TAG)) { return; } |