Repository navigation
fix(core): keep every selector of assigned style blocks (#248, #249, #250) - #251
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
An assigned `<style>` block was a class map unless it was exported, applied, or read as `theme.$class`, and a class map commented out its element and descendant rules. `$class` is an ordinary string, so any path the static check could not see (destructuring, a holding object, a prop, a return value, iteration) dropped the styles while the element still carried the hash class. RFC #1 states the rule: an assigned block keeps all its selectors, because `apply` and `$class` can attach its hash anywhere. The dead-CSS carve-out that kept pre-RFC class-map pruning for local blocks is removed: - the analyzer marks every assigned block `styleKind: 'theme'` and drops the classification-only `styleExported` and `styleClassRead` metadata; - `prepare_stylesheet_for_render` prunes nothing in any mode, so the `'class-map'` mode and the boolean form render as `'theme'` for consumers that still pass them; - the class-map selector marking that only served pruning is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`createScopes` skipped every identifier whose parent was a TypeScript node, which also dropped the value-level wrappers `value as T`, `value!`, `value satisfies T`, and `fn<T>`. These read the binding at runtime, so they now count as references; type positions such as `typeof value` still do not. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leonidaz
force-pushed
the
fix/theme-class-destructure-248
branch
from
September 24, 2026 17:44
2b4deb7 to
26b7c3e
Compare
This was referenced Sep 24, 2026
Closed
Merged
This branch was successfully deployed
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.
Fixes #248. Fixes #249. Fixes #250.
The rule
An assigned
<style>block keeps every selector. It is always a theme and is never pruned. This is what RFC #1 states under "Pruning underapply": "an assigned block keeps all its selectors, each scoped under its own$classhash, becauseapplycan attach that hash anywhere."Root cause
The same RFC section added a dead-CSS carve-out: a block that is neither exported nor applied "keeps today's class-map pruning". That pruning dates from 0994c17 (#1262), from before themes existed, when
const styles = <style>could only be read through class entries. The$classaddendum then made a block a theme only when a static check saw atheme.$classread (is_class_read).$classis an ordinary string. Any path the check couldn't see left the block a class map, and its element rules were emitted only as/* (unused) … */comments, with no diagnostic, while the element still carried the hash class. Examples:const { $class: cls } = theme), [Bug]: Destructuring a theme's $class drops its element styles #248;themes.red.$class), [Bug]: Destructuring a theme's $class drops its element styles #248;theme!ortheme as T, [Bug]: createScopes dropsx as T,x!, andx satisfies Tas references, so theme $class reads through them are missed #250.Whether an element receives
$classis ordinary JavaScript data flow, so no static check can decide it.Changes
Assigned blocks are never pruned:
style-analyze.js: every assigned block getsstyleKind: 'theme'. The classification (collect_exported_names,is_class_read) and itsstyleExported/styleClassReadmetadata are removed.scoping.js:prepare_stylesheet_for_renderprunes nothing in any mode. The signature is unchanged;'class-map'and the boolean form now render as'theme', so a consumer passing them can't prune an assigned block.style-ref.js:mark_class_map_selectorsand theclass_map_selectorstamp, which only fed pruning, are removed.'theme'for assigned blocks.Consumers: Ripple (
@tsrx/ripplestyle-scopes.js) and Octane (style-scopes.js) both pick the render mode withstyleKind === 'theme' ? 'theme' : 'class-map', so they keep every selector after bumping@tsrx/core, with no code change.Output change: an element that carries a class entry (
styles.card) also carries the hash, so the block's element rules now match it..cardstill beatsdivon specificity.#250,
createScopes:value as T,value!,value satisfies T, andfn<T>are now references. The reference visitor skipped every identifier whose parent was aTS*node, which also dropped these runtime reads. Type positions (typeof value) are still excluded. With the rule above this no longer affects styles, butbinding.referencesis public API that Ripple and Octane use.Docs:
llms.txt, spec 4.5.3 and the metadata appendix, the features page, the core README, the MCP docs index, and the conformance fixture README now state the rule. Theassigned-positionsconformance fixture expects nothing pruned.Verification
const theme = <style>div { color: red; }</style>; const { $class: cls } = theme;now emitsdiv.<hash> { color: red; }on React, Preact, Solid, Vue, and Hono. It was/* (unused) … */before.theme!. The analyzer tests assertstyleKind: 'theme'in every position. AcreateScopestest covers the TS wrappers; it fails without the scope change.pnpm test(118 files, 5527 tests),pnpm typecheck,pnpm format:check, andpnpm changeset:checkpass.Release note
@tsrx/coreisminor: the language rule changes (more CSS is emitted), and the publicstyleExported/styleClassReadmetadata and theClassMapCollectionStatetype are removed.@tsrx/mcpispatchfor the regenerated docs.Downstream
Ripple and Octane pick their render mode from
styleKind, so they get the rule from a@tsrx/corebump. Each has a follow-up issue listing the tests and docs that assert class-map pruning. I found them by running each repo's suite against this branch.style-identifier,scoped-styles), docs.minimumReleaseAgeExclude, 2 tests (style-map,style), docs.Both repos also drop a style block's CSS from the SSR response when
$classis read outside a render. Once pruning is gone, that gap is the remaining way these patterns render unstyled on first paint: Ripple-TS/ripple#1515 (any module-level read) and octanejs/octane#1310 (an imported theme read at module scope).🤖 Generated with Claude Code