Add tree construction tests for void elements inside phrasing containers#194
Draft
nghamilton wants to merge 1 commit intohtml5lib:masterfrom
Draft
Add tree construction tests for void elements inside phrasing containers#194nghamilton wants to merge 1 commit intohtml5lib:masterfrom
nghamilton wants to merge 1 commit intohtml5lib:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The existing tree construction test suite has no test cases for void elements (
<br>,<input>,<img>,<wbr>,<embed>) as children of<p>, heading, or formatting elements.This is a gap because the "in body" insertion mode handles these void elements via the "reconstruct the active formatting elements, insert an HTML element, pop" path - but a buggy parser could incorrectly route them through
closePElementinstead, causing<p><br></p>to produce<p></p><br>(closing the paragraph before inserting the break).The combination
<p><br></p>is common in real-world HTML.Test cases (13)
<br>inside<p>(with/without surrounding text, multiple<br>s) - 5 cases<br>inside<h1>- 1 case<input>,<img>,<wbr>,<embed>inside<p>- 4 cases<input>inside<h2>- 1 case<br>inside formatting elements (<em>,<strong>) - 2 casesAll test cases use
<!DOCTYPE html>prefix (no parse errors expected).These tests add coverage for void elements (
<br>,<input>,<img>,<wbr>,<embed>) as children of phrasing containers (<p>, headings, formatting elements). The html5lib reference parser already handles these cases correctly - the gap is in test suite coverage. These tests help other implementations catch a class of bug. CI failures are pre-existing and unrelated to this PR (parse5 hasn't implemented recent<select>content model changes).Relevant spec sections
area, br, embed, img, keygen, wbrcase reconstructs active formatting elements, inserts, and immediately pops. It must NOT call the "close a p element" algorithm.