css: inline a theme token already declared at root scope#149
Open
samoht wants to merge 1 commit into
Open
Conversation
resolve_theme kept a theme token live when the input already carried its own
root-scope definition (`:root,:host{--blur-xl:24px}`, exactly what Tailwind
emits): it added the token to the keep-set and injected a second `:root`
binding, so `var(--blur-xl)` survived unresolved beside two definitions. It now
inlines from the existing declaration and drops it, injecting a binding only for
tokens with no declaration of their own.
Two supporting changes: the inline engine recognises a `:root,:host` list (any
list with a `:root` branch), not just a bare `:root`, as a whole-tree value
source; and the theme layer is unified on bare custom-property names so the
keep/declared/resolved sets compare without mixing `--`-prefixed spellings.
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.
This PR makes
resolve_themeinline a theme token whose definition is already present in the input.When a stylesheet already carries a token's own root-scope definition (
:root,:host{--blur-xl:24px}, which is exactly what Tailwind's codegen emits for theme tokens),resolve_themeused to keep the token live and inject a second:rootbinding, leavingvar(--blur-xl)unresolved beside two definitions. It now inlines the reference from the existing declaration and drops it, injecting a:rootbinding only for tokens that have no declaration of their own; the in-stylesheet value wins over thetheme_defaultsdefault, matching the cascade.Two supporting changes make that work: the inline engine now recognises a
:root,:hostlist (or any list with a:rootbranch), not just a bare:root, as a whole-tree value source, so the declared value actually reaches the references; and the theme-resolution layer is unified on bare custom-property names so the keep/declared/resolved sets compare directly instead of mixing---prefixed and bare spellings.Follow-up to #148.