Repository navigation
fix(citry): read the Vue mount host's nesting the way browsers do - #782
Merged
Merged
Conversation
The check that `on_serialize` hooks kept the Vue mount host now uses a parser that opens and closes elements where a browser does, so an end tag a browser ignores, a `</p>` or `</br>` that creates an element, and the elements a start tag closes are read as the browser reads them. The parser lives in `citry.util._markup_tree`, with tests of the trees it builds and of the host check. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
Inside an open `<select>`, an end tag now closes an element opened inside the select, `</select>` closes everything opened inside it, and `</br>` and `</p>` create an element there, as in Chromium, Firefox and WebKit. Adds tests for these trees, for the host check, and one test through a real `on_serialize` hook. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
JuroOravec
added a commit
that referenced
this pull request
Nov 18, 2026
…s do The parser behind the checks of rendered slot fills now reads <select> content the way Chromium, Firefox and WebKit do. Inside an open select, an end tag closes an element opened inside the select, </select> closes the select and everything inside it, and </br> and </p> create an element there. <input> and a nested <select> close an open select, and the end tag of the table cell, caption or template around a select closes the select with it. The copy of the parser in citry (PR #782) needs the same rules; a note in this module says the two copies are kept in step. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
The mount host check's copy of the markup tree parser now follows the same `<select>` rules as citry-ui's copy: `</select>` closes everything inside the select, `</br>` and `</p>` inside a select create an element, `<input>` and a nested `<select>` close the open select, and the end tag of the table cell, caption, row, section or table around a select (or `</template>`) closes the select with it. The tree tests from citry-ui cover each rule. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
JuroOravec
added a commit
that referenced
this pull request
Nov 18, 2026
…s do (#783) The parser behind the checks of rendered slot fills now reads <select> content the way Chromium, Firefox and WebKit do. Inside an open select, an end tag closes an element opened inside the select, </select> closes the select and everything inside it, and </br> and </p> create an element there. <input> and a nested <select> close an open select, and the end tag of the table cell, caption or template around a select closes the select with it. The copy of the parser in citry (PR #782) needs the same rules; a note in this module says the two copies are kept in step. Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
What changed
After extension
on_serializehooks run, Citry checks that the page still holds the element Vue mounts on: one<div id="...">, in the form Citry wrote, closed, and empty when the page has no server HTML in it. That check counted nesting with a simple depth counter. It now reads nesting the way browsers do:</link>, no longer ends the element early.</p>and</br>with nothing to close create an element, as in a browser.<p>before a<div>.</form>,<select>content, and<style>inside SVG or MathML are read the way browsers read them.The parser that does this is new in
citry/util/_markup_tree.py. It follows the parser citry-ui uses for its output checks, and citry does not import citry-ui. It also fixes the rule for end tags inside an open<select>: an end tag closes an element opened inside the select,</select>closes the select and everything opened inside it, and</br>and</p>create an element there, as Chromium, Firefox and WebKit do. citry-ui's copy of the parser still has the earlier select rule; a follow-up can apply the same fix there.The other
HTMLParsersubclasses in citry (_IdScanner,_PreloadHeadLocator,_PreparedMarkupTracker) already ignore an end tag that matches no open element, so they do not need this change.Why
A hook result that a browser reads correctly, such as one with a
<p>closed by a later<div>, could fail the check with "Vue serialization hooks must preserve exactly one empty Citry mount host". Content after an end tag that a browser ignores could also be read as outside the element.Tests
packages/py/citry/tests/test_markup_tree.py(new). It checks the trees the parser builds, including the new select cases, the host check on pages whose expected trees were read from Chromium, Firefox and WebKit, and one end-to-end test through a realon_serializehook.ruff checkandruff format --check(ruff 0.14.13, the locked version) on the touched files: clean.mypy packages/py/citry/citry, also with--platform linux: no issues in 211 files.pyteston the citry tests for Vue, extensions, serialization and the HTML parsers: 2,613 passed, 1 xfailed. Three modules were not collected because they importcitry_ui, which this environment does not install.The parser copy in this PR matches the
<select>rules of the citry-ui copy in #783, andtest_markup_tree.pyholds the same tree cases.Versioning
This is a patch-level fix. The check accepts every page it accepted before, except a page whose mount element a browser leaves open or fills with content. It now also accepts pages that a browser reads correctly but the old counter refused. No public API changes; the new module is private. A root
CHANGELOG.mdline is under Unreleased, and theon_serialize()row indocs/design/trust_boundaries.mdis updated.🤖 Generated with Claude Code
https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED