You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Preserve var() in animation shorthand
The animation shorthand parser was silently dropping var() function
tokens because they did not match any of the time/timing/direction/
fill-mode/play-state/iteration classifiers. For example,
animation: shimmer var(--animation-duration, 1.5s) infinite
would lose the var() and emit only animationName + animationIterationCount.
Recognize var() tokens and assign them positionally per CSS shorthand
semantics: bind to the longhand hinted by the var()'s fallback when
possible, otherwise fall back to the next free time slot
(duration first, then delay).
Co-authored-by: Kenneth Skovhus <skovhus@users.noreply.github.com>
* Bail when animation var() type cannot be inferred
Per review: previously, var() tokens with no classifiable fallback
(e.g. `var(--anim-token)`) were coerced into a duration/delay slot.
This silently miscompiles cases like `${kf} var(--anim-token) 2s
infinite` where `--anim-token: ease-in` resolves at runtime — the
browser would treat `2s` as the duration.
Now bail and emit a warning when an animation shorthand contains a
var() whose runtime longhand position cannot be determined statically.
The shorthand is left intact (no transformation), preserving original
semantics. Users can rebind the variable to a specific longhand
(e.g. `animation-duration: var(--x)`) to opt in to transformation.
Co-authored-by: Kenneth Skovhus <skovhus@users.noreply.github.com>
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Copy file name to clipboardExpand all lines: src/internal/logger.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -110,7 +110,8 @@ export type WarningType =
110
110
|"Using styled-components components as mixins is not supported; use css`` mixins or strings instead"
111
111
|"styled(ImportedComponent) wraps a component whose file contains internal styled-components — convert the base component's file first to avoid CSS cascade conflicts"
112
112
|"Transient $-prefixed props renamed on exported component — update consumer call sites to use the new prop names"
113
-
|"Shorthand property has an opaque value that StyleX will expand to longhands — use `directional` in resolveValue to return separate longhand tokens";
113
+
|"Shorthand property has an opaque value that StyleX will expand to longhands — use `directional` in resolveValue to return separate longhand tokens"
114
+
|"animation shorthand contains a var() with no classifiable fallback — its longhand position cannot be determined statically; bind the variable to a specific longhand (e.g. animation-duration: var(--x)) instead";
Copy file name to clipboardExpand all lines: src/internal/lower-rules/rule-interpolated-declaration.ts
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -345,10 +345,18 @@ export function handleInterpolatedDeclaration(args: InterpolatedDeclarationConte
345
345
filePath,
346
346
avoidNames,
347
347
applyResolvedPropValue,
348
+
bailUnsupportedUnknownVar: ()=>
349
+
bailUnsupportedLocal(
350
+
decl,
351
+
"animation shorthand contains a var() with no classifiable fallback — its longhand position cannot be determined statically; bind the variable to a specific longhand (e.g. animation-duration: var(--x)) instead",
// @expected-warning: animation shorthand contains a var() with no classifiable fallback — its longhand position cannot be determined statically; bind the variable to a specific longhand (e.g. animation-duration: var(--x)) instead
2
+
// var() inside an animation shorthand with no classifiable fallback type is
3
+
// unsupported because we cannot statically determine which longhand position
4
+
// it should map to (could be duration, timing-function, etc. at runtime).
5
+
// Coercing it would miscompile cases like `--anim-token: ease-in` where the
6
+
// browser would treat the following `2s` as the duration.
0 commit comments