43081j / postcss-lit

PostCSS syntax for extracting CSS from template literals inside JS/TS files
84 stars 6 forks source link

fix: unescape backslashes on the way into the parser #52

Closed 43081j closed 6 months ago

43081j commented 6 months ago

We already account for escape sequences added to the AST later on (i.e. something like stylelint, postcss, etc has mutated it).

However, we do not unescape sequences on the way into the parser.

For example:

css`
  .foo {
    content: "\\abc";
  }
`;

This is already escaped, once for JS, once for the resulting CSS.

When we parse this, we extract the CSS and keep the double-escape. This of course means the resulting CSS file internally has one too many escapes.

Fixes #51 To account for this, we now unescape CSS on the way in (i.e. replace double escapes with single).

github-actions[bot] commented 6 months ago

Pull Request Test Coverage Report for Build 7159393284


Totals Coverage Status
Change from base Build 4308425324: 0.01%
Covered Lines: 901
Relevant Lines: 909

💛 - Coveralls