Repository navigation
fix: don't double-escape scoped names with postcss-selector-parser 7.2.0 - #71
Open
denniskigen wants to merge 1 commit into
Open
denniskigen wants to merge 1 commit into
denniskigen wants to merge 1 commit into
Conversation
postcss-selector-parser 7.2.0 escapes values passed to the className() constructor. The scoped name we pass is already escaped (css-loader escapes it in generateScopedName), so it was escaped twice and the selector no longer matched the exported class. Pass the unescaped name as `value` and the escaped spelling as `raws.value`, matching how the parser represents a class it parsed itself. Do the same for ids, which postcss-selector-parser#360 would also start escaping. The trailing hex escape check now reads the serialised spelling, since `value` is no longer escaped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
postcss-selector-parser 7.2.0 started escaping values passed to the
className()constructor (postcss/postcss-selector-parser#349). We pass it a scoped name that's already escaped (css-loader escapes the name before returning it fromgenerateScopedName), so it now gets escaped twice. A name likeF+JnE5oCZsS0FV+Mxzn6Mg==comes out as.F\\\+JnE5oCZsS0FV\\\+Mxzn6Mg\\\=\\\=, which doesn't match the exported class, so the styles never apply. We hit this in OpenMRS, where every CSS module class in our app shell stopped matching. Reported in postcss/postcss-selector-parser#362.This passes the unescaped name as
valueand the escaped spelling asraws.value, which is how the parser represents a class it parsed itself. The parser leavesraws.valuealone, so the output is the same on 7.0.0, 7.1.8 and 7.2.0. I've done the same for ids, since postcss/postcss-selector-parser#360 makes theid()constructor escape too.With
valueunescaped, the check that keeps the space after a trailing hex escape (.\1F600 .foo) has to look at the serialised spelling, so it now usesstringifyProperty("value"). Without that,escape-sequencefails.The new
escaped-scoped-namescase returns pre-escaped names the way css-loader does. It fails on 7.2.0 without this change.