Skip to content

Commit 901d986

Browse files
fix: do not localize animation-name property with var and env functions
1 parent 36e67d5 commit 901d986

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,13 @@ function localizeDeclarationValues(localize, declaration, context) {
316316
const valueNodes = valueParser(declaration.value);
317317

318318
valueNodes.walk((node, index, nodes) => {
319+
if (
320+
node.type === "function" &&
321+
(node.value.toLowerCase() === "var" || node.value.toLowerCase() === "env")
322+
) {
323+
return false;
324+
}
325+
319326
if (
320327
node.type === "word" &&
321328
specialKeywords.includes(node.value.toLowerCase())

test/index.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,26 @@ const tests = [
160160
input: ".foo { animation-name: bar; }",
161161
expected: ":local(.foo) { animation-name: :local(bar); }",
162162
},
163+
{
164+
name: "not localize animation-name in a var function",
165+
input: ".foo { animation-name: var(--bar); }",
166+
expected: ":local(.foo) { animation-name: var(--bar); }",
167+
},
168+
{
169+
name: "not localize animation-name in a var function #2",
170+
input: ".foo { animation-name: vAr(--bar); }",
171+
expected: ":local(.foo) { animation-name: vAr(--bar); }",
172+
},
173+
{
174+
name: "not localize animation-name in an env function",
175+
input: ".foo { animation-name: env(bar); }",
176+
expected: ":local(.foo) { animation-name: env(bar); }",
177+
},
178+
{
179+
name: "not localize animation-name in an env function #2",
180+
input: ".foo { animation-name: eNv(bar); }",
181+
expected: ":local(.foo) { animation-name: eNv(bar); }",
182+
},
163183
{
164184
name: "not localize a single animation-delay",
165185
input: ".foo { animation-delay: 1s; }",

0 commit comments

Comments
 (0)