Skip to content

🐛 fix: pop open select for a keygen start tag in select mode#154

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/93-keygen-in-select
Jun 18, 2026
Merged

🐛 fix: pop open select for a keygen start tag in select mode#154
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/93-keygen-in-select

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

parse("<select><keygen>z") nested the keygen inside the open <select> instead of popping the select and placing keygen as a sibling after it. The WHATWG "in select" insertion mode handles input, keygen, and textarea the same way — pop until the select is popped, then reprocess (and ignore the token in a select-context fragment that has no select in scope). turbohtml implemented this for input but let keygen fall through to a plain insert. Closes #93.

keygen now goes through the same handler as input. I verified the direction against the reference: html5lib's library pops the select (keygen becomes a sibling) for a document and ignores keygen in a select fragment, matching the algorithm. The pinned html5lib-tests .dat predates the keygen rule and still nests it, so the two affected cases (tests7.dat <select><keygen>, tests_innerHTML_1.dat <keygen><option> in select) are pinned to the spec-correct trees through the existing _SPEC_OVERRIDES table — the same mechanism already used for the stale foreign </p>/</br> cases (#32/#63).

No benchmark: the change adds keygen to an existing start-tag branch, off any hot path.

The "in select" insertion mode pops an open select for an input, keygen, or
textarea start tag (ignoring it in a select-context fragment). turbohtml
implemented this for input but let keygen fall through to a normal insert,
nesting it inside the select.

Handle keygen alongside input. html5lib's library and the WHATWG algorithm
pop the select; the pinned html5lib-tests .dat predates the keygen rule and
still nests it, so the two affected cases are pinned to the spec-correct
trees through the existing override table.
@gaborbernat gaborbernat added the bug Something isn't working label Jun 18, 2026
@gaborbernat gaborbernat enabled auto-merge (squash) June 18, 2026 06:56
@gaborbernat gaborbernat disabled auto-merge June 18, 2026 07:11
@gaborbernat gaborbernat merged commit 2f50f30 into tox-dev:main Jun 18, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spec: <keygen> in "in select" mode nests instead of closing select

1 participant