Skip to content

Commit

Permalink
fix: do not tread negative values as identifiers in the animation sho…
Browse files Browse the repository at this point in the history
…rthand (#68)
  • Loading branch information
alexander-akait authored Dec 21, 2023
1 parent 7f06bbb commit 87fa2e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 87fa2e8

Please sign in to comment.