Skip to content

Commit

Permalink
fix: Allow to disable animation prefix (#14822)
Browse files Browse the repository at this point in the history
* fix: Allow to disable animation prefix

* Apply suggestions from code review

---------

Co-authored-by: Paolo Ricciuti <[email protected]>
  • Loading branch information
ai and paoloricciuti authored Dec 24, 2024
1 parent 1d773ef commit 38a3ae3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/twenty-shoes-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: don't include keyframes in global scope in the keyframes to rename
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ function is_global_block_selector(simple_selector) {
);
}

/**
*
* @param {Array<AST.CSS.Node>} path
*/
function is_in_global_block(path) {
return path.some((node) => node.type === 'Rule' && node.metadata.is_global_block);
}

/** @type {CssVisitors} */
const css_visitors = {
Atrule(node, context) {
if (is_keyframes_node(node)) {
if (!node.prelude.startsWith('-global-')) {
if (!node.prelude.startsWith('-global-') && !is_in_global_block(context.path)) {
context.state.keyframes.push(node.prelude);
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/svelte/tests/css/samples/global-block/expected.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
animation: svelte-xyz-test 1s;
}

.y{
animation: test-in 1s;
}

@keyframes test-in{
to{
opacity: 1;
Expand Down
4 changes: 4 additions & 0 deletions packages/svelte/tests/css/samples/global-block/input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
animation: test 1s;
}
.y{
animation: test-in 1s;
}
@keyframes test-in{
to{
opacity: 1;
Expand Down

0 comments on commit 38a3ae3

Please sign in to comment.