Skip to content

fix(server): retain keyframes across animation shorthand components - #1537

Open
pcbeingused333 wants to merge 1 commit into
callstack:masterfrom
pcbeingused333:fix/c2799-animation-keyframes
Open

pcbeingused333 wants to merge 1 commit into
callstack:masterfrom
pcbeingused333:fix/c2799-animation-keyframes

Conversation

@pcbeingused333

Copy link
Copy Markdown

Motivation

Critical CSS collection in @linaria/server drops referenced @keyframes when the animation name is not the first space-separated word of the declaration, or when a declaration lists several animations. For example, animation: 1s linear spin loses @keyframes spin (while animation: spin 1s linear keeps it), so the element does not animate until the rest of the CSS loads. With animation: spin 1s, fade 2s, only spin is kept; animation-name: spin, fade keeps neither.

The cause is decl.value.split(' ')[0] in collect.ts, which only takes the first word of the whole value.

Summary

Collect candidate names from every comma-separated animation and every whitespace-separated component, using postcss.list.comma / postcss.list.space (which keep steps(2, end) and cubic-bezier(...) intact). The tokens are still only matched against the names of existing @keyframes rules, so unreferenced keyframes stay out of the critical CSS. Includes a patch changeset for @linaria/server.

Test plan

New test.each cases in packages/server/__tests__/collect.test.ts cover duration-first and middle names, tabs and newlines, multiple shorthands, timing functions with commas, and comma-separated animation-name; each also checks that an unused keyframe is not collected. Against the current collect.ts, 6 of the 7 cases fail (only spin 1s linear passes); with the change all 7 pass.

AI assistance: this change and its regression tests were generated with Codex.

@changeset-bot

changeset-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 980e1d4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@linaria/server Patch
@linaria/atomic Patch
@linaria/core Patch
@linaria/babel-plugin-interop Patch
linaria Patch
@linaria/postcss-linaria Patch
@linaria/react Patch
@linaria/stylelint-config-standard-linaria Patch
@linaria/stylelint Patch

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

This branch has not been deployed

No deployments
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