Skip to content

fix(citry): read the Vue mount host's nesting the way browsers do - #782

Merged
JuroOravec merged 4 commits into
mainfrom
fix/host-validator-parser
Nov 18, 2026
Merged

JuroOravec merged 4 commits into
mainfrom
fix/host-validator-parser

Conversation

@JuroOravec

@JuroOravec JuroOravec commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

What changed

After extension on_serialize hooks 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:

  • An end tag a browser ignores, such as </link>, no longer ends the element early.
  • </p> and </br> with nothing to close create an element, as in a browser.
  • A start tag closes what a browser closes for it, such as an open <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 HTMLParser subclasses 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 real on_serialize hook.
  • ruff check and ruff 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.
  • pytest on the citry tests for Vue, extensions, serialization and the HTML parsers: 2,613 passed, 1 xfailed. Three modules were not collected because they import citry_ui, which this environment does not install.

The parser copy in this PR matches the <select> rules of the citry-ui copy in #783, and test_markup_tree.py holds 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.md line is under Unreleased, and the on_serialize() row in docs/design/trust_boundaries.md is updated.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED

JuroOravec and others added 2 commits November 18, 2026 13:58
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
JuroOravec and others added 2 commits November 18, 2026 14:37
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
JuroOravec merged commit 7c2b05d into main Nov 18, 2026
24 of 33 checks passed
@JuroOravec
JuroOravec deleted the fix/host-validator-parser branch November 18, 2026 14:37
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant