Skip to content

Ask the token assertions of :root, where the light theme lives - #454

Merged
jmchilton merged 1 commit into
mainfrom
license-tokens-root
Aug 6, 2026
Merged

Ask the token assertions of :root, where the light theme lives#454
jmchilton merged 1 commit into
mainfrom
license-tokens-root

Conversation

@jmchilton

Copy link
Copy Markdown
Member

A defect in the assertion #453 added, found while writing the sibling instance's copy of it — that repo asks this question of :root and carries a comment explaining why, because it had already been caught by it once.

What was wrong

licenseBadgeStyleGaps was handed the whole emitted stylesheet. .dark is a class, and a class is not tree-shaken — so a token declared only under .dark is present in that string whether or not :root ever got one. The search finds the dark value and reports the light theme healthy.

Demonstrated rather than reasoned about. Moving --color-license-verbatim out of @theme and into .dark:

  • all 18 assertions in the file passed
  • declares no token that reaches no stylesheet also passed, correctly — the token is no longer declared in @theme, so it is not a dead token
  • and every verbatim OK chip on the site renders with no background in light mode, correct in dark

That is close to the least likely combination to be caught in review: the reviewer on a dark editor sees nothing wrong.

The fix

The palette check one screen above was already written about this exact trap — its comment names --color-rail-on and --color-tag-bg-hover as tokens it caught that way. It extracted :root inline. That extraction is now a named rootCss() helper, and both assertions go through it.

Re-running the same simulation against the fix fails it, naming the token:

tokens the badge reads and this site never declares: expected [ '--color-license-verbatim' ] to deeply equal []

Verification

303 tests across 21 files, astro check 0 errors. No source or stylesheet change — this is the test file only.

The licence-token check searched the whole emitted stylesheet, so a token
declared only under .dark satisfied it — a class is not tree-shaken, so the
search finds the dark value and reports the light one healthy. Demonstrated:
move --color-license-verbatim into .dark and all 18 assertions passed while
every verbatim chip lost its background in light mode.

The palette check one screen above was already written about exactly this
trap. Its :root extraction is now a named helper both go through.
@jmchilton
jmchilton merged commit 94be857 into main Aug 6, 2026
1 check passed
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.

1 participant