Repository navigation
Check that Leaf writes its classes and data attributes under its prefix - #5273
Merged
Merged
Conversation
#5050 and #5244 moved the classes and data attributes Leaf writes on its own elements under `lf-` and `data-lf-`, the names `page check` refuses an author, so a page's CSS can't restyle Leaf by naming one. Nothing kept the next write there: each sweep was a grep, and the second found about eighty names the first missed. `test_leaf_writes_its_own_marks_under_its_prefix` reads every runtime and bundled package module through a new `marks` reading in `tests/js_facts.mjs`. It parses each module with oxc and its templates and HTML strings with parse5's tokenizer, and collects each class and `data-` attribute the module writes: in a start tag, through `className`, `dataset`, `classList.add` or `toggle`, `setAttribute` or `toggleAttribute`, `keeps`, or the class handed to `el` and the offer builders. The test fails on a name outside the prefix unless it is one of two kinds of name Leaf writes without owning: - An author's: the idioms and tones the registries declare, such as `label.choice`, `[data-room]` and `.ok`, which the theme draws alike on Leaf's own controls. The test reads them from the registries, so a new idiom needs no edit. - A library's, on an element Leaf draws for that library: Pierre's `data-code`, `data-line-type` and `data-overflow` on lf-diff's rows, and markdown-it's `task-list-item-checkbox`, which the composer's editor draws too. It reads 1,464 writes in 336 modules, and found one name #5244 missed: the composer's attachment shelf carried the `scroll` class, so a page rule for `.scroll` reached it. The shelf now carries `data-lf-scroll`, which the theme's scroller rule (`controls.css`) and the runtime's scroll edges (`reach.js`) already read beside the authored `.scroll`. A name built from a dynamic part, such as `lf-${kind}`, goes unread. > _This was written by Claude Code on behalf of max-sixty_
leaf-agent
approved these changes
Nov 4, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 4, 2026
…5288) Leaf drew four of its controls with names a page writes for its own: `data-room` on a thread's summary toggle and news notice, lf-diff's file count and a playground's Apply; `.choice` on the command reference's preference and a playground's or visual review's checkbox and radio labels; `.primary` on every commit face; and `.ok` on a tally's chip once nothing is left to answer. A page's CSS for those names restyled Leaf's controls. On the code-comparison example, a page style of `.choice { outline: … }` and `[data-room] > * { white-space: normal }` outlined the playground's own choice labels and Apply button, and stopped the button cutting its words. #5273's check let them through, since it allowed every name a registry declares for authors, and it couldn't see `primary`, which comes from the control faces table. Leaf now has one rule, stated in browser/AGENTS.md ("Leaf's elements wear only Leaf's names"): a class or data attribute the runtime or a package module writes is `lf-` or `data-lf-`, and where a Leaf control looks like an idiom an author writes, it wears the idiom's `lf-` twin and one theme rule selects both, as `.lf-btn` and `.button` already did. A page restyles Leaf on purpose through the theme's tokens. - `data-lf-room` beside `data-room`: controls.css lays out both, each `::before` reading its own attribute. - `.lf-choice` beside `.choice`, with Web Awesome's radio and checkbox region scoped to both (build/styles.mjs). - The commit face is `lf-btn lf-commit`, and the theme draws `:is(.lf-btn.lf-commit, .button.primary)`. - A tally's done chip carries `data-lf-tone="ok"`, the attribute Leaf already gives its own tones; chip.css tints `.lf-chip[data-lf-tone]` and an author's `.tag.ok` in an option alike. Each selector keeps its specificity, since `:is()` takes its heaviest argument's. What a page writes is unchanged. `test_leaf_writes_its_own_marks_under_its_prefix` now allows only the four library names and reads the control faces table too; it fails on the old tally chip and commit face. `test_controls_are_built_by_role_and_never_by_face` drops its check for the words `button` and `primary`, which the marks check now owns. module-authoring.md tells a package author which names a module's own controls wear. A thread's news notice also held the room of the count it first said, so "9 new" growing to "10 new" was cut. It now holds the widest count it says, `NEWS_ROOM` ("99 new" in figures of one width), so it stands one figure wider while its first count has one figure. > _This was written by Claude Code on behalf of max-sixty_
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.
#5050 and #5244 moved the classes and data attributes Leaf writes on its own elements under
lf-anddata-lf-, the namespage checkrefuses an author, so a page's CSS can't restyle Leaf by naming one. Nothing kept the next write there: each sweep was a grep, and the second found about eighty names the first missed.test_leaf_writes_its_own_marks_under_its_prefixreads every runtime and bundled package module through a newmarksreading intests/js_facts.mjs. It parses each module with oxc and its templates and HTML strings with parse5's tokenizer, and collects each class anddata-attribute the module writes: in a start tag, throughclassName,dataset,classList.addortoggle,setAttributeortoggleAttribute,keeps, or the class handed toeland the offer builders. The test fails on a name outside the prefix unless it is one of two kinds of name Leaf writes without owning:label.choice,[data-room]and.ok, which the theme draws alike on Leaf's own controls. The test reads them from the registries, so a new idiom needs no edit.data-code,data-line-typeanddata-overflowon lf-diff's rows, and markdown-it'stask-list-item-checkbox, which the composer's editor draws too.It reads 1,464 writes in 336 modules, and found one name #5244 missed: the composer's attachment shelf carried the
scrollclass, so a page rule for.scrollreached it. The shelf now carriesdata-lf-scroll, which the theme's scroller rule (controls.css) and the runtime's scroll edges (reach.js) already read beside the authored.scroll.A name built from a dynamic part, such as
lf-${kind}, goes unread.Checks
class="lf-composer-media scroll".