Repository navigation
fix(core): validate refs in compound @-shorthand values - #316
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 506969e The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The embedded/compound branch of resolvePropertyValue recorded usage but skipped validateReference, so a compound @-shorthand referencing an undefined variable silently emitted a dead var(--…) instead of throwing like the single exact-ref path. Call validateReference for each ref part in the embedded branch, mirroring the single-ref path exactly. Implements SF-13.
alexgrozav
force-pushed
the
agent/roux/6bc5039c
branch
from
July 15, 2026 07:05
e1d7684 to
506969e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
What
Validate variable references inside compound
@-shorthand values.resolvePropertyValueinengine/core/src/tokens/resolve.tsalready threw for a single exact ref (padding: "@0.5"), but the embedded/compound branch (padding: "@0.25 @0.5",border: "1px solid @undefined") only recorded usage and skippedvalidateReference— so a compound ref to an undefined variable silently emitted a deadvar(--…). The embedded branch now callsvalidateReferencefor each ref part, mirroring the single-ref path.Why
A compound
@-shorthand referencing an undefined variable produced invalid CSS (e.g.padding: var(--0--25) var(--0--5)) with no error, while the single-ref form correctly threw. This closes that gap so both paths validate identically. Implements SF-13 (split out from SF-12).Output diff (silent → throw)
The only behavior change is for compound refs to undefined variables:
Compound refs whose variables are all defined are unchanged — byte-for-byte identical output:
How verified
Repo-wide audit for compound
@-shorthand refs to undefined variables: theme (3320 tests, incl.calc(@tooltip.arrow.size * -1)etc.) is clean;apps/storybookcompound refs (calc(@spacing * N),1px solid @color.primary,1px solid @border-color,@spacing.sm @spacing,*.arrow.size) all resolve to defined variables. One known undefined compound ref remains — the chat-message story padding@0.25 @0.5— tracked separately under SF-12; not touched here.Notes
@styleframe/core+styleframe, patch).resolve/css/declarationsembedded-ref tests referenced undefined variables as fixtures; they now define the variables first, since the compound path validates. New tests cover: compound undefined ref throws, one-of-several undefined throws, all-defined compiles.parseAtReferencestreats@inside a larger token as a reference, sourl("image@2x.png")(a retina filename) is parsed as ref2x.png— silentlyvar(--2x--png)onmain, and now a throw. Neutralized the one incidental core-test fixture that hit it; recommend a follow-up to boundary-guard the parser. Not fixed here to keep this change scoped.