Skip to content

test(cli): guard public component theme vars against being documented but unsettable - #5409

Merged
cixzhang merged 1 commit into
mainfrom
test/theme-var-wiring-guard
Aug 24, 2026
Merged

cixzhang merged 1 commit into
mainfrom
test/theme-var-wiring-guard

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Problem

A theme author reads --tree-list-indent in the TreeList docs, writes the
override, and has no way to find out whether it did anything. Two shapes have
already shipped where it did nothing:

  • #5012 — the theme docs
    taught --button-press-scale, which no component read. A theme setting it
    compiled to a declaration nothing consumed.
  • #4530 — TreeList's indent
    was written as an inline longhand on the element carrying the theme target.
    Inline outranks every cascade layer, so @layer astryx-theme could not reach
    it. The var was real, read, and documented, and still unsettable.

Neither is visible in the generated theme CSS, which is the artifact the jsdom
suites assert on — TreeList.test.tsx says so in as many words: "jsdom cannot
resolve the @layer cascade, so the generated CSS is what proves the override
reaches the lever."
It proves the declaration was emitted. That is a different
claim.

What this adds

collectThemingVars joins collectThemingTargets in
packages/cli/foundation/discovery/theming-targets.mjs, so the public vars come
out of the same enumeration the theme targets listing and theme build
validation already read. Private --_* plumbing is excluded — it is not a
theme's to set.

Two checks ride on it, both against live source:

check catches
every documented public var is read by the component that documents it #5012
no documented public var is written inline, where no theme can outrank it #4530

What it catches today

Zero on main — all four documented public vars
(--button-focus-offset, --button-icon-only-aspect, --tree-list-indent,
--tree-list-row-gap) are read from a StyleX rule and none is written inline.

A guard that fires zero times is unfalsifiable, so both were run against the two
shapes that actually shipped. Re-adding --button-press-scale to
Button.doc.mjs fails with Button: nothing reads var(--button-press-scale);
moving --tree-list-row-gap back to an inline style={{}} on the TreeList root
fails with TreeList: TreeList.tsx sets --tree-list-row-gap inline.

What it does not prove

Whether the theme's declaration then wins the cascade on the element. That is a
browser fact — no jsdom test can stand in for it, and this PR does not pretend
to. The file docblock says so.

Test plan

pnpm test — 11725 passed, 2 failures both pre-existing macOS
case-insensitivity (hook-discovery, component dispatcher), unrelated.

No runtime code changes; nothing renders differently.

… but unsettable

collectThemingVars joins collectThemingTargets as part of the one theming
enumeration, and two checks ride on it. A documented public var no component
reads compiles to a declaration that never applies (#5012). A var the component
writes inline outranks every cascade layer, so no theme can reach it (#4530).
Both shipped, and neither is visible in the generated theme CSS, which is the
artifact the jsdom suites assert on.
@vercel

vercel Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 24, 2026 7:39am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 24, 2026
@cixzhang
cixzhang enabled auto-merge (squash) August 24, 2026 07:37
@cixzhang
cixzhang merged commit 3c52d51 into main Aug 24, 2026
18 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Aug 24, 2026
@github-actions
github-actions Bot deleted the test/theme-var-wiring-guard branch August 25, 2026 06:12

This branch was successfully deployed

1 active deployment
Preview — 9880bef5 Deployed Aug 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant