Skip to content

fix: do not tread negative values as identifiers in the animation shorthand #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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