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

Handle illegal self-closing according to spec #136

Closed
apeschar opened this issue Dec 4, 2017 · 4 comments
Closed

Handle illegal self-closing according to spec #136

apeschar opened this issue Dec 4, 2017 · 4 comments
Assignees
Labels

Comments

@apeschar
Copy link
Contributor

apeschar commented Dec 4, 2017

Browsers will parse

<div />
<span>Hello, World!</span>
</div>

like this (proof)

<div>
<span>Hello, World!</span>
</div>

Whereas this parser will parse it like this

<div></div>
<span>Hello, World!</span>

This is because the Tokenizer emits endTag after all self-closing tags. It should really only do this for tags that may be self-closed (ie, void elements and foreign elements).

apeschar added a commit to apeschar/html5-php that referenced this issue Dec 4, 2017
apeschar added a commit to apeschar/html5-php that referenced this issue Dec 4, 2017
@goetas
Copy link
Member

goetas commented Aug 21, 2018

This makes sense but most probably is a BC break 😿

@mundschenk-at
Copy link
Contributor

Is it rally a BC break if the parser gets closer to spec (or browser behavior, as an extension of the spec)?

@apeschar
Copy link
Contributor Author

Right. The README starts with "HTML5 is a standards-compliant HTML5 parser". It isn't quite, but fixing this bug would get it a little closer.

@goetas goetas added the bug label Aug 21, 2018
@apeschar
Copy link
Contributor Author

apeschar commented Aug 21, 2018

The title of this issue is a bit confusing because I did not understand that this browser behaviour is according to spec until I investigated further. See the URL I linked in my PR. Self-closing tags do not exist in HTML5, are an error, and therefore ignored by browsers, except for foreign elements.

See also: https://www.w3.org/TR/html5/syntax.html#start-tags

@apeschar apeschar changed the title Handle illegal self-closing tags like the browser does Handle illegal self-closing according to spec Aug 21, 2018
@goetas goetas self-assigned this Sep 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants