Skip to content

Commit 0bbe17e

Browse files
committed
add global for animations
1 parent 5eeb305 commit 0bbe17e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,17 @@ function localizeDeclarationValues(localize, declaration, context) {
328328
return false;
329329
}
330330

331+
// replace `animation-name: global(example)` with `animation-name: example`
332+
if (
333+
node.type === "function" &&
334+
node.value.toLowerCase() === "global" &&
335+
/animation(-name)$/i.test(declaration.prop) &&
336+
node.nodes.length === 1
337+
) {
338+
Object.assign(node, node.nodes[0]);
339+
return;
340+
}
341+
331342
if (
332343
node.type === "word" &&
333344
specialKeywords.includes(node.value.toLowerCase())

test/index.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ const tests = [
175175
input: ".foo { animation-name: env(bar); }",
176176
expected: ":local(.foo) { animation-name: env(bar); }",
177177
},
178+
{
179+
name: "not localize animation-name in an global function",
180+
input: ".foo { animation-name: global(bar); }",
181+
expected: ":local(.foo) { animation-name: bar; }",
182+
},
178183
{
179184
name: "not localize animation-name in an env function #2",
180185
input: ".foo { animation-name: eNv(bar); }",

0 commit comments

Comments
 (0)