Skip to content

Commit 38a3ae3

Browse files
aipaoloricciuti
andauthored
fix: Allow to disable animation prefix (#14822)
* fix: Allow to disable animation prefix * Apply suggestions from code review --------- Co-authored-by: Paolo Ricciuti <[email protected]>
1 parent 1d773ef commit 38a3ae3

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

.changeset/twenty-shoes-peel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: don't include keyframes in global scope in the keyframes to rename

packages/svelte/src/compiler/phases/2-analyze/css/css-analyze.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,19 @@ function is_global_block_selector(simple_selector) {
2828
);
2929
}
3030

31+
/**
32+
*
33+
* @param {Array<AST.CSS.Node>} path
34+
*/
35+
function is_in_global_block(path) {
36+
return path.some((node) => node.type === 'Rule' && node.metadata.is_global_block);
37+
}
38+
3139
/** @type {CssVisitors} */
3240
const css_visitors = {
3341
Atrule(node, context) {
3442
if (is_keyframes_node(node)) {
35-
if (!node.prelude.startsWith('-global-')) {
43+
if (!node.prelude.startsWith('-global-') && !is_in_global_block(context.path)) {
3644
context.state.keyframes.push(node.prelude);
3745
}
3846
}

packages/svelte/tests/css/samples/global-block/expected.css

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
animation: svelte-xyz-test 1s;
7575
}
7676

77+
.y{
78+
animation: test-in 1s;
79+
}
80+
7781
@keyframes test-in{
7882
to{
7983
opacity: 1;

packages/svelte/tests/css/samples/global-block/input.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
animation: test 1s;
7777
}
7878
79+
.y{
80+
animation: test-in 1s;
81+
}
82+
7983
@keyframes test-in{
8084
to{
8185
opacity: 1;

0 commit comments

Comments
 (0)