Repository navigation
Conversation
…ium does The HTML Standard dropped the "in select" and "in select in table" modes in July 2025 (whatwg/html#10548); Chromium has parsed <select> so since version 134. A select and its options now hold what is written in them (<div>, <b>, <p>, tables, svg, links, images), where parse5 kept only the text and <option>, <optgroup> and <hr>. StandardParser now drops parse5's switches to the select modes (an insertionMode accessor), counts <select> as a bound of every scope, reads <select>, <option>, <optgroup>, <hr> and <input> by the new rules while a select is open in scope, and reads </select> as one of the body's block end tags. A count of open selects keeps pages without one from walking the stack for it. Markdown skips the select itself, but what follows it can change (<p>a <select><b>x</select>b</p> is "a **b**"), and links and images in options are now collected. Random pages and fragments of select, form-control, table, template and formatting tags now match Chromium 151 in every case (1,480 to 1,530 of 5,000 per run differed before); the 120 captured pages give the same output. EXTRACTOR_VERSION is now extract-tf/18. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: 77777R7 <lunhoward306@gmail.com>
This was referenced Oct 3, 2026
Closed
Closed
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.
Stacked on #151 (
claude/parse5-foreign-end); it retargets as the stack merges. This fixes the last Known gap from #137, Chromium's newer<select>parsing.Problem
In July 2025 the HTML Standard dropped the "in select" and "in select in table" insertion modes (whatwg/html#10548, part of customizable
<select>). Chromium has parsed<select>that way since version 134; our oracle runs Chromium 151. parse5 8.0.1 still uses the old modes. Inside a select it kept only text,<option>,<optgroup>and<hr>, and it dropped every other tag.<select><div>a</div><option>b</select><select><div>a</div><option>b</option></select><select>a<option>b</option></select><select><b>a</select>b<select><b>a</b></select><b>b</b><select>a</select>b<p><select><p>x<p><select><p>x</p></select></p><p><select>x</select></p><select><textarea>t</textarea>x<select><textarea>t</textarea>x</select><select></select><textarea>t</textarea>x<table><select><input type=hidden>x<select><input type="hidden">x</select><table></table><select></select>x<table><input type="hidden"></table>Change
packages/extract-tf/src/dom.ts,StandardParser, following the live standard (parsing.html#parsing-main-inbody):insertionModeaccessor onStandardParser.prototypedrops parse5's switches to IN_SELECT and IN_SELECT_IN_TABLE. This covers every path, including those that call parse5's in-body handler directly: after head, after body, and the template's top level. The reset of the insertion mode no longer has a select branch.<select>bounds every scope.hasInScope,hasInButtonScope,hasInListItemScopeandhasNumberedHeaderInScopeare replaced byscoped(), whose HTML bounds includeselect.inSelect):<select>pops to the open select;<option>and<optgroup>generate implied end tags;<hr>closes a<p>, then generates implied end tags;<input>pops the select. In the table modes, a hidden<input>follows the table's own rule.</select>is read as one of the body's block end tags: it generates implied end tags and pops to the select.onItemPushandonItemPop) lets a page without a select skip the scope walk entirely.scoped()also avoids closures.EXTRACTOR_VERSIONis nowextract-tf/18. Markdown skips the select itself, but what follows can change:<p>a <select><b>x</select>b</p>givesa **b**, nota b. Links and images inside options are now collected, as they are in the browser's DOM. The version test's digest is unchanged.Tests
packages/extract-tf/test/tables.test.ts. Every expected tree is Chromium's. 9 of its 10 assertions fail on fix(extract-tf): match end tags in and around svg and math as Chromium does #151's code; the<input>one guards behavior that is unchanged.npm run typecheck: exit 0.npm test: 145 files, 1842 tests passed.Chromium oracle (151.0.7922.34)
Random inputs of select, option, optgroup, form controls, table, template and formatting tags:
<select>, and each gives the same tree as before.Review
A fresh-context reviewer found nothing blocking. It checked:
It also raised one non-blocking speed point: the select-in-scope check walked the stack for every
<input>,<option>or<hr>. The count of open selects fixes that. At 60,000 nested<span>,<input>takes 95 ms (126 before),<option>85 ms (132), and<select></select>111 ms (7.2 s). The reviewer then checked the counter against the actual stack after every push and pop over 120,000 random inputs: it found 0 mismatches and the same trees with or without the gate.Known gaps
<selectedcontent>: Chromium clones the selected option's content into it, which this does not yet do. It is next. Fixed in feat(extract-tf): copy a select's selected option into its <selectedcontent>, as Chromium does #156.<hr>are slow in parse5 itself (about 12–22 s at 60,000 nested<span>), unchanged by this PR. A select that holds a deep stack now meets the same cost, because its content stays on the stack as in Chromium.🤖 Generated with Claude Code