Skip to content

Commit 308e6ca

Browse files
committed
add test for keyframes
1 parent 776792e commit 308e6ca

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ module.exports = (options = {}) => {
555555
} else if (
556556
atRule.params &&
557557
!globalMode &&
558-
!localAliasMap.has(atRule.params)
558+
!localAliasMap.has(atRule.params) &&
559+
!hasIgnoreComment(atRule)
559560
) {
560561
atRule.params = ":local(" + atRule.params + ")";
561562
}

test/index.test.js

+38
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,44 @@ const tests = [
10771077
&:disabled { animation-name: :local(localAnimation); }
10781078
}`,
10791079
},
1080+
{
1081+
name: "verify ignore comment doesn't affect subsequent rules",
1082+
options: { mode: "pure" },
1083+
input: `/* cssmodules-pure-ignore */
1084+
.global { color: blue; }
1085+
.local { color: red; }`,
1086+
expected: `/* cssmodules-pure-ignore */
1087+
.global { color: blue; }
1088+
:local(.local) { color: red; }`,
1089+
},
1090+
{
1091+
name: "handle ignore comments in media queries",
1092+
options: { mode: "pure" },
1093+
input: `@media screen {
1094+
/* cssmodules-pure-ignore */
1095+
.global { color: blue; }
1096+
.local { color: red; }
1097+
}`,
1098+
expected: `@media screen {
1099+
/* cssmodules-pure-ignore */
1100+
.global { color: blue; }
1101+
:local(.local) { color: red; }
1102+
}`,
1103+
},
1104+
{
1105+
name: "handle ignore comments with keyframes",
1106+
options: { mode: "pure" },
1107+
input: `/* cssmodules-pure-ignore */
1108+
@keyframes global-fade {
1109+
from { opacity: 0; }
1110+
to { opacity: 1; }
1111+
}`,
1112+
expected: `/* cssmodules-pure-ignore */
1113+
@keyframes global-fade {
1114+
from { opacity: 0; }
1115+
to { opacity: 1; }
1116+
}`,
1117+
},
10801118
{
10811119
name: "handle negative animation-delay in animation shorthand",
10821120
input: ".foo { animation: 1s -500ms; }",

0 commit comments

Comments
 (0)