Skip to content

Commit

Permalink
fix: do not localize animation-name property with var and env funct…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
alexander-akait authored May 23, 2023
1 parent 36e67d5 commit 901d986
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,13 @@ function localizeDeclarationValues(localize, declaration, context) {
const valueNodes = valueParser(declaration.value);

valueNodes.walk((node, index, nodes) => {
if (
node.type === "function" &&
(node.value.toLowerCase() === "var" || node.value.toLowerCase() === "env")
) {
return false;
}

if (
node.type === "word" &&
specialKeywords.includes(node.value.toLowerCase())
Expand Down
20 changes: 20 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,26 @@ const tests = [
input: ".foo { animation-name: bar; }",
expected: ":local(.foo) { animation-name: :local(bar); }",
},
{
name: "not localize animation-name in a var function",
input: ".foo { animation-name: var(--bar); }",
expected: ":local(.foo) { animation-name: var(--bar); }",
},
{
name: "not localize animation-name in a var function #2",
input: ".foo { animation-name: vAr(--bar); }",
expected: ":local(.foo) { animation-name: vAr(--bar); }",
},
{
name: "not localize animation-name in an env function",
input: ".foo { animation-name: env(bar); }",
expected: ":local(.foo) { animation-name: env(bar); }",
},
{
name: "not localize animation-name in an env function #2",
input: ".foo { animation-name: eNv(bar); }",
expected: ":local(.foo) { animation-name: eNv(bar); }",
},
{
name: "not localize a single animation-delay",
input: ".foo { animation-delay: 1s; }",
Expand Down

0 comments on commit 901d986

Please sign in to comment.