Skip to content

Check that Leaf writes its classes and data attributes under its prefix - #5273

Merged
max-sixty merged 1 commit into
mainfrom
list-ui-fixes
Nov 4, 2026
Merged

max-sixty merged 1 commit into
mainfrom
list-ui-fixes

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

#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.

Checks

  • The new test, which fails on class="lf-composer-media scroll".
  • Browser tests for a margin reply with a pasted image and for an attached image in the floating panel.

This was written by Claude Code on behalf of max-sixty

#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_
@max-sixty
max-sixty merged commit d0f8424 into main Nov 4, 2026
4 checks passed
@max-sixty
max-sixty deleted the list-ui-fixes branch November 4, 2026 01:04
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_
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.

2 participants