Repository navigation
fix(server): retain keyframes across animation shorthand components - #1537
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 980e1d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 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 |
This branch has not been 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.
Motivation
Critical CSS collection in
@linaria/serverdrops referenced@keyframeswhen 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 spinloses@keyframes spin(whileanimation: spin 1s linearkeeps it), so the element does not animate until the rest of the CSS loads. Withanimation: spin 1s, fade 2s, onlyspinis kept;animation-name: spin, fadekeeps neither.The cause is
decl.value.split(' ')[0]incollect.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 keepsteps(2, end)andcubic-bezier(...)intact). The tokens are still only matched against the names of existing@keyframesrules, so unreferenced keyframes stay out of the critical CSS. Includes a patch changeset for@linaria/server.Test plan
New
test.eachcases inpackages/server/__tests__/collect.test.tscover duration-first and middle names, tabs and newlines, multiple shorthands, timing functions with commas, and comma-separatedanimation-name; each also checks that an unused keyframe is not collected. Against the currentcollect.ts, 6 of the 7 cases fail (onlyspin 1s linearpasses); with the change all 7 pass.AI assistance: this change and its regression tests were generated with Codex.