Skip to content

fix: preserve selector delimiters after escaped backslashes - #354

Open
wozhenbang2004 wants to merge 2 commits into
postcss:mainfrom
wozhenbang2004:fix/escaped-backslash-delimiters
Open

wozhenbang2004 wants to merge 2 commits into
postcss:mainfrom
wozhenbang2004:fix/escaped-backslash-delimiters

Conversation

@wozhenbang2004

Copy link
Copy Markdown

When a class name ends in an escaped backslash, a following . or # starts a new selector node. splitWord() currently treats every delimiter immediately preceded by a backslash as escaped and merges the nodes.

Count consecutive backslashes before the delimiter so an even number leaves it active and an odd number still escapes it. The regression tests exercise both delimiters, escaped delimiters after a backslash, and lossless round trips.

The two new delimiter cases fail on the unmodified parser. npm test passed all 905 tests on Node.js 24, including the coverage thresholds.

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.

1 participant