Skip to content

fix(postcss): preserve source escapes in changed fields - #1509

Merged
Anber merged 1 commit into
masterfrom
anber/fix-partial-field-escaping
Aug 5, 2026
Merged

fix(postcss): preserve source escapes in changed fields#1509
Anber merged 1 commit into
masterfrom
anber/fix-partial-field-escaping

Conversation

@Anber

@Anber Anber commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Motivation

When a fixer rewrites only part of a selector or declaration value, the field-wide source snapshot no longer matches. The stringifier therefore treats the entire field as newly generated and escapes source-derived backslashes again.

Closes #1508.

Summary

  • expose the original field value to the stringifier
  • tokenize original and changed fields into CSS escapes and surrounding text
  • preserve retained escape tokens while still escaping newly introduced ones
  • conservatively treat duplicate escapes as fixer-owned when their count changes
  • bound the comparison size and fall back to the existing safe behavior
  • cover declaration values, mixed selector escapes, and ambiguous duplicates

Validation

  • 5 Jest suites, 100 tests, 13 snapshots
  • focused stringify suite on Node.js 24
  • TypeScript typecheck
  • ESLint
  • Prettier

@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 57c31cb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@linaria/postcss-linaria Patch
@linaria/atomic Patch
@linaria/babel-plugin-interop Patch
@linaria/core Patch
@linaria/react Patch
@linaria/server Patch
@linaria/stylelint Patch
@linaria/stylelint-config-standard-linaria Patch
linaria Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Anber
Anber marked this pull request as ready for review August 5, 2026 11:55
@Anber
Anber merged commit d3b131d into master Aug 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@linaria/postcss-linaria: fixers double source backslashes in the field they rewrite

1 participant