fix(publisher): stop pruning runtime-toggled state rules from publish… - #541
Open
fortusfederal wants to merge 1 commit into
Open
fortusfederal wants to merge 1 commit into
fortusfederal wants to merge 1 commit into
Conversation
…ed CSS
A rule such as `.drawer.is-open` never reached the published stylesheet.
`selectorBindingClassName` returned the rightmost class token, so the CSS
importer stored the rule as a bindable class named `is-open`. The publisher's
tree-shaker gates class-kind rules on `usedIds.has(rule.id)`, and a class that
only exists because a script calls `classList.add('is-open')` is never in any
node's `classIds` — so the rule was silently dropped at publish time while
still rendering correctly in the editor canvas.
The binding was wrong in the first place: assigning that rule to a node writes
`class="is-open"`, which alone never matches `.drawer.is-open`.
A subject compound holding two or more classes now has no unambiguous binding
and classifies as ambient, where the existing tree-shaker logic already does
the right thing — unknown class tokens do not veto a rule, so the state rule
survives on its used base class. Single-class subjects qualified by an
attribute or pseudo (`.drawer[data-open]`, `.drawer:hover`) still bind, and
Tailwind-style variants (`.group:hover .group-hover\:block`) are unchanged,
including still being tree-shaken when unassigned.
Verified: bun test (10 pre-existing unrelated failures, unchanged),
bun run build, bun run lint.
fortusfederal
marked this pull request as ready for review
September 18, 2026 00:59
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.
Summary
A rule such as
.drawer.is-opennever reaches the published stylesheet, while rendering correctly in the editor canvas.selectorBindingClassNamereturns the rightmost class token, so the CSS importer stores the rule as a bindable class namedis-open. The publisher's tree-shaker gates class-kind rules onusedIds.has(rule.id), and a class that exists only because a script callsclassList.add('is-open')is never in any node'sclassIds— so the rule is silently dropped at publish time.The binding was wrong to begin with: assigning that rule to a node writes
class="is-open", which alone never matches.drawer.is-open. A subject compound holding two or more classes now has no unambiguous binding, so it is not treated as a bindable class and is no longer subject to usage-based pruning.Verification
bun run buildbun testbun run lintChecklist
styleRuleTreeShake.test.ts,cssSelectorClasses.test.ts,cssToStyleRules.test.tsdocs/reference/css-class-registry.md🤖 Generated with Claude Code