Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add special case for end tag </br>. Fixes #185 #186

Merged
merged 1 commit into from
Jun 24, 2020

Conversation

IMSoP
Copy link
Contributor

@IMSoP IMSoP commented Jun 24, 2020

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.

closes #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.
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.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that triggering a parse error is needed. Will the returned DOM still be as expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just going by the wording of the spec, which has a specific definition of "parse error" in terms of declaring a document non-conformant, even where the result is well-defined.

The DOM should look exactly as though this was a normal void <br> tag with no attributes, so I'm happy to remove this line if you want to limit parseError to more serious problems.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have parse errors for stuff like duplicate IDs, so ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@goetas goetas merged commit d7961a8 into Masterminds:master Jun 24, 2020
@goetas
Copy link
Member

goetas commented Jun 24, 2020

thank you!

lyrixx pushed a commit to lyrixx/html5-php that referenced this pull request Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retain closing br tag as though it were a normal br tag
3 participants