diff --git a/src/index.js b/src/index.js index 142c9fd..391507c 100644 --- a/src/index.js +++ b/src/index.js @@ -357,7 +357,7 @@ function localizeDeclaration(declaration, context) { // We don't validate `hex digits`, because we don't need it, it is work of linters. const validIdent = - /^-?([a-z\u0080-\uFFFF_]|(\\[^\r\n\f])|-)((\\[^\r\n\f])|[a-z\u0080-\uFFFF_0-9-])*$/i; + /^-?([a-z\u0080-\uFFFF_]|(\\[^\r\n\f])|-(?![0-9]))((\\[^\r\n\f])|[a-z\u0080-\uFFFF_0-9-])*$/i; /* The spec defines some keywords that you can use to describe properties such as the timing diff --git a/test/index.test.js b/test/index.test.js index f08f916..e0428f9 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -864,6 +864,21 @@ const tests = [ options: { mode: "pure" }, expected: ":export { foo: __foo; }", }, + { + name: "handle negative animation-delay in animation shorthand", + input: ".foo { animation: 1s -500ms; }", + expected: ":local(.foo) { animation: 1s -500ms; }", + }, + { + name: "handle negative animation-delay in animation shorthand #1", + input: ".foo { animation: 1s -500.0ms; }", + expected: ":local(.foo) { animation: 1s -500.0ms; }", + }, + { + name: "handle negative animation-delay in animation shorthand #2", + input: ".foo { animation: 1s -500.0ms -a_value; }", + expected: ":local(.foo) { animation: 1s -500.0ms :local(-a_value); }", + }, ]; function process(css, options) {