Skip to content

fix: the ASCII whitespaces are preserved so can not be escaped #1632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JounQin
Copy link
Contributor

@JounQin JounQin commented Apr 16, 2025

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

close #1626

Breaking Changes

N/A

Additional Info

related https://infra.spec.whatwg.org/#ascii-whitespace

cc @alexander-akait

@JounQin JounQin changed the title fix: ASCII whitespaces are preserved can can not be escaped fix: the ASCII whitespaces are preserved so can not be escaped Apr 16, 2025
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.50%. Comparing base (f5be49c) to head (6bd4494).
Report is 43 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1632      +/-   ##
==========================================
+ Coverage   96.15%   96.50%   +0.34%     
==========================================
  Files          10       10              
  Lines        1196     1201       +5     
  Branches      461      460       -1     
==========================================
+ Hits         1150     1159       +9     
  Misses         37       37              
+ Partials        9        5       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

color: red;
}

.\\ > .\\ > .\\ {
.- > .- > .- {
color: red;
}
",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a test case

a-b { }
a\C20b { } /* i.e. with spaces */

The main problem we need to generate different CSS selectors for such case.

Even more - I think we should replace each control character on own unique symbol, we can generate it from code the character, so even special characters will always generate and unique selector. What do you think?

Copy link
Contributor Author

@JounQin JounQin Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a test case

OK, I'll add such case soon.

The main problem we need to generate different CSS selectors for such case.

Even more - I think we should replace each control character on own unique symbol, we can generate it from code the character, so even special characters will always generate and unique selector. What do you think?

That could work as expected, but is that common to have different white spaces in a single project? Is that a bit over engineering? But I'm also fine if you have strong opinion on this. What the symbol map would you prefer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could work as expected, but is that common to have different white spaces in a single project?

Usually no, but I think we can solve it more universal for any exotic cases, usually developers don't use such characters in path and in CSS selectors too 😄

I think we can just generate use number of a character... yeah it will create more longer CSS selectors, maybe we can use some compression algorithm here to get less length

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually developers don't use such characters in path and in CSS selectors too

I got this issue because we installed a common package in global mode. What means whenever css-loader is installed as global, it will be an issue for macOS at least with Application Support dir.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JounQin got it, let's fix it

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.

CSS modules with path which contains spaces does not work as expected
2 participants