fix: the ASCII whitespaces are preserved so can not be escaped#1668
fix: the ASCII whitespaces are preserved so can not be escaped#1668JounQin wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds coverage and updates escaping behavior for CSS Modules local identifiers, particularly around reserved/whitespace characters, to address issue #1626.
Changes:
- Added a regression test + fixtures for
"modules" optionissue #1626. - Changed
escapeLocalIdentto escape reserved/whitespace characters using hex-style escape sequences (and updated snapshots accordingly). - Updated spellchecker config to ignore generated test outputs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/modules-option.test.js | Adds a new regression test for issue #1626 under the "modules" option suite. |
| test/fixtures/modules/issue-1626/source.js | Adds a JS entry fixture that imports the CSS fixture for issue #1626. |
| test/fixtures/modules/issue-1626/source.css | Adds a CSS selector fixture intended to cover escaping around spaces/special chars. |
| test/snapshots/modules-option.test.js.snap | Updates snapshots to reflect the new escaping output and adds snapshots for issue #1626. |
| src/utils.js | Changes escapeLocalIdent escaping strategy for reserved/whitespace characters. |
| .cspell.json | Ignores test/outputs in spellchecking. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .replace(filenameReservedRegex, (_, $1) => { | ||
| // normalize Windows path `\` as unix `/` for constancy | ||
| const char = $1 === "\\" ? "/" : $1; | ||
|
|
||
| if (reversedChartMapper[char]) { | ||
| return reversedChartMapper[char]; | ||
| } | ||
|
|
||
| const hex = char.charCodeAt(0).toString(16).toUpperCase(); | ||
| const escaped = `\\C${hex}`; | ||
|
|
||
| reversedChartMapper[char] = escaped; | ||
|
|
||
| return escaped; | ||
| }) |
| .replace(filenameReservedRegex, (_, $1) => { | ||
| // normalize Windows path `\` as unix `/` for constancy | ||
| const char = $1 === "\\" ? "/" : $1; | ||
|
|
||
| if (reversedChartMapper[char]) { | ||
| return reversedChartMapper[char]; | ||
| } | ||
|
|
||
| const hex = char.charCodeAt(0).toString(16).toUpperCase(); | ||
| const escaped = `\\C${hex}`; | ||
|
|
||
| reversedChartMapper[char] = escaped; | ||
|
|
||
| return escaped; | ||
| }) |
| a\C20b /* i.e. with spaces */ { | ||
| color: red; |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1668 +/- ##
==========================================
+ Coverage 96.25% 96.28% +0.02%
==========================================
Files 10 10
Lines 1201 1210 +9
Branches 463 462 -1
==========================================
+ Hits 1156 1165 +9
Misses 40 40
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
alexander-akait
left a comment
There was a problem hiding this comment.
Let's fix copilot review and we can merge, note - generation classes with such characters is a little bit different in experiments.css than here, but it is fine
|
@alexander-akait I just fixed the typo and believe the left copilot reviews are invalid, can you confirm? |
This PR contains a:
Motivation / Use-Case
close #1626
Breaking Changes
N/A
Additional Info
related https://infra.spec.whatwg.org/#ascii-whitespace
cc @alexander-akait