Repository navigation
fix(citry-ui): read <select> content in checked fills the way browsers do - #783
Merged
Merged
Conversation
…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
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
Several citry-ui components check the slot fills they render, for example that a
CImageplaceholder holds nothing focusable, or that eachCAccordionitem is one closed root element. They read the rendered HTML withMarkupTreeParser(citry_ui/components/_markup_tree.py, added in #778). That parser now reads<select>content the way Chromium, Firefox and WebKit do:</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
CAccordionor 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
MarkupTreeParserrow indocs/design/trust_boundaries.mdalso 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 theCAccordionand 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 validCAccordionitems that the old rule refused now pass, and three items with a hidden extra root are refused.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 checkandruff 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(withoute2e/andtest_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 onmain, 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