Skip to content

fix(citry-ui): read <select> content in checked fills the way browsers do - #783

Merged
JuroOravec merged 4 commits into
mainfrom
fix/citry-ui-markup-tree-select
Nov 18, 2026
Merged

JuroOravec merged 4 commits into
mainfrom
fix/citry-ui-markup-tree-select

Conversation

@JuroOravec

@JuroOravec JuroOravec commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

What changed

Several citry-ui components check the slot fills they render, for example that a CImage placeholder holds nothing focusable, or that each CAccordion item is one closed root element. They read the rendered HTML with MarkupTreeParser (citry_ui/components/_markup_tree.py, added in #778). That parser 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, and </select> closes the select and everything opened inside it. Before, the parser ignored every end tag other than those of the select and its options, so it refused valid fills such as <div><select><option><div>i</div>a</option></select></div>.
  • </br> creates a <br> there, and a </p> with no paragraph opened inside the select creates an empty one inside it.
  • <input> and a nested <select> close an open select (the browser drops the nested tag), and </template> or the end tag of the table cell or caption around a select (or of its row, section or table) closes the select with it.

The first two rules match the fix in #782, which copies this parser into citry for the Vue mount check. The review of this PR found the third group. Without it, the new end-tag rule would let a CAccordion or Menu fill pass with an extra root element. The three rules are checked against the three browsers.

The module docstring says citry keeps a copy of this parser and that the two copies are kept in step. #782 needs the third group of rules too. A matching patch for its copy is ready and will be handed to that PR.

The class docstring and the MarkupTreeParser row in docs/design/trust_boundaries.md also list two limits the parser already had and still has. It does not model a formatting element such as <b> that a browser opens again. Outside a select, it does not close a table cell for a later <td> or <tr>, or for </td>, </tr> or </table> while a <div> is open in the cell. Either one can hide an extra root from the CAccordion and Menu checks. These checks guard layout and focus, not script: a fill is author or app markup. A follow-up can model the table-cell rules.

Tests

  • tests/test_markup_tree.py: 11 new browser-tree cases (valid select pages, </p> and </br> in a select, <input>, nested select, cell, caption, table and template end tags). I checked each expected tree against Chromium, Firefox and WebKit with Playwright (DOMParser). All of the select cases match.
  • tests/test_output_parsers.py: two valid CAccordion items that the old rule refused now pass, and three items with a hidden extra root are refused.
  • On main's parser, 10 of the 11 new tree cases and the root-count test fail. The eleventh checks an end tag that both versions ignore.
  • ruff check and ruff format --check (0.14.13) on the touched files: clean.
  • mypy packages/py/citry_ui/citry_ui, also with --platform linux: no issues in 323 files.
  • pytest packages/py/citry_ui/tests (without e2e/ and test_citry_ui_type_check.py, which needs citry-lsp): 1,824 passed.

Review

An independent reviewer ran a security pass ("Text and markup", "Parser rules browsers differ on") and a prose pass, comparing about 100 cases in the three browsers and rendering the probe fills through CAccordion. Its findings are fixed here: the start-tag and table end-tag rules above, a CCommandPalette activator case that the <input> rule now refuses, a test that used a reopened <b>, and prose fixes. Every route is author-only by design. The table-cell gap outside a select is on main, is in no release, and is documented above.

Versioning

citry-ui is 0.x, so the 1.x promise does not cover it. No stored or exchanged format changes. The code is in no release, so the existing Unreleased "Fixed" entry from #778 now names <select> content instead of getting a new line.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED

…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
JuroOravec merged commit 692112c into main Nov 18, 2026
30 checks passed
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