Environment
@linaria/postcss-linaria: master (c7b0360e)
- PostCSS: 8.4.31
- Node.js: 24.16.0
- OS: macOS
Description
Follow-up to #1497, as promised there.
The fix compares each field against its source snapshot, so a field nothing touches keeps its backslashes. When a fixer rewrites a field that also contains a source-derived escape, the whole field counts as changed and the untouched escape gets escaped again — the same corruption as #1497, with a narrower trigger.
Reproduction
sample.style.ts:
import { css } from '@linaria/core';
export const style = css`
.foo {
content: '\u2022';
}
`;
const { readFileSync } = require('fs');
const syntax = require('@linaria/postcss-linaria');
const source = readFileSync('sample.style.ts', 'utf8');
const doc = syntax.parse(source, { from: 'sample.style.ts' });
// stand-in for a fixer that rewrites the value — here only the quote style
doc.walkDecls((decl) => {
decl.value = decl.value.replace(/'/g, '"');
});
let out = '';
syntax.stringify(doc, (s) => {
out += s;
});
console.log(out);
Expected:
Actual:
Skipping the walkDecls call leaves '\u2022' intact, so this only happens when a fixer writes to the same field.
In practice it is reached by any fixable rule that rewrites a value or a selector containing a backslash — quote normalisation over content: '\u2022', or a selector fixer touching a selector that contains \:.
Environment
@linaria/postcss-linaria: master (c7b0360e)Description
Follow-up to #1497, as promised there.
The fix compares each field against its source snapshot, so a field nothing touches keeps its backslashes. When a fixer rewrites a field that also contains a source-derived escape, the whole field counts as changed and the untouched escape gets escaped again — the same corruption as #1497, with a narrower trigger.
Reproduction
sample.style.ts:Expected:
Actual:
Skipping the
walkDeclscall leaves'\u2022'intact, so this only happens when a fixer writes to the same field.In practice it is reached by any fixable rule that rewrites a value or a selector containing a backslash — quote normalisation over
content: '\u2022', or a selector fixer touching a selector that contains\:.