postcss-css-variables icon indicating copy to clipboard operation
postcss-css-variables copied to clipboard

Escaped Class Names Using Vars Incorrectly Set to `undefined`

Open shellscape opened this issue 2 years ago • 2 comments

Consider the following CSS:

.bg-\\[url\\(https\\:\\/\\/example\\.com\\/image\\.png\\)\\] {
  --un-url: url(https://example.com/image.png); background-image:var(--un-url);
}

The output from running the plugin is:

.bg-\\[url\\(https\\:\\/\\/example\\.com\\/image\\.png\\)\\] {
  background-image:undefined;
}
.bg-\\[url\\(https\\:\\/\\/example\\.com\\/image\\.png\\)\\]:\\/\\/example\\.com\\/image\\.png\\)\\]{
  background-image:url(https://example.com/image.png);
}

The plugin seems to have an issue with escaping, or a variable directly following escaping.

shellscape avatar Nov 29 '23 04:11 shellscape

This https://github.com/resendlabs/react-email/blob/3be21ad8a8f073d4e1a61c3ee94d40522c769674/patches/postcss-css-variables%400.19.0.patch#L4 seems to be a patch for the issue.

shellscape avatar Nov 29 '23 04:11 shellscape

Here's an additional reproduction set:

Input: .xl\\:bg-green-500{--un-bg-opacity:1;background-color:rgb(34 197 94 / var(--un-bg-opacity));}

Expected: .xl\\:bg-green-500{background-color:rgb(34 197 94 / 1);}

Actual: .xl\\:bg-green-500{background-color:undefined}.xl\\:bg-green-500:bg-green-500{background-color:rgb(34 197 94/1)}

shellscape avatar Nov 29 '23 19:11 shellscape