From 308e6ca00070c60eb090b1caae2d526e021de392 Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Thu, 31 Oct 2024 18:27:34 +0100 Subject: [PATCH] add test for keyframes --- src/index.js | 3 ++- test/index.test.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index b556643..878d38a 100644 --- a/src/index.js +++ b/src/index.js @@ -555,7 +555,8 @@ module.exports = (options = {}) => { } else if ( atRule.params && !globalMode && - !localAliasMap.has(atRule.params) + !localAliasMap.has(atRule.params) && + !hasIgnoreComment(atRule) ) { atRule.params = ":local(" + atRule.params + ")"; } diff --git a/test/index.test.js b/test/index.test.js index 9f78ea4..313524f 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -1077,6 +1077,44 @@ const tests = [ &:disabled { animation-name: :local(localAnimation); } }`, }, + { + name: "verify ignore comment doesn't affect subsequent rules", + options: { mode: "pure" }, + input: `/* cssmodules-pure-ignore */ + .global { color: blue; } + .local { color: red; }`, + expected: `/* cssmodules-pure-ignore */ + .global { color: blue; } + :local(.local) { color: red; }`, + }, + { + name: "handle ignore comments in media queries", + options: { mode: "pure" }, + input: `@media screen { + /* cssmodules-pure-ignore */ + .global { color: blue; } + .local { color: red; } + }`, + expected: `@media screen { + /* cssmodules-pure-ignore */ + .global { color: blue; } + :local(.local) { color: red; } + }`, + }, + { + name: "handle ignore comments with keyframes", + options: { mode: "pure" }, + input: `/* cssmodules-pure-ignore */ + @keyframes global-fade { + from { opacity: 0; } + to { opacity: 1; } + }`, + expected: `/* cssmodules-pure-ignore */ + @keyframes global-fade { + from { opacity: 0; } + to { opacity: 1; } + }`, + }, { name: "handle negative animation-delay in animation shorthand", input: ".foo { animation: 1s -500ms; }",