You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
CSS modules with path which contains spaces does not work as expected #1626
import*asstylesfrom'./space folder/render.module.css';exportfunctionrender(){constel=document.createElement('div');el.className=styles.text;// styles.text contains a space which breaks stylingdocument.getElementsByTagName('body')[0].appendChild(el);el.innerHTML='hello, world';}
The generated class is src-space folder-render-module__text-WVNeAh which contains a space, but it's not possible to escape spaces, so the spaces in path should be changed to __ for example.
Yeah, technically we have CSS.escape to escape special character before inserting them in JS and it works good for non space characters, but there are some limitation with the class attribute
CSS.escape('1@a'); // -> \\31 \\@a, and you can using them in HTML class attribute
CSS.escape('a b'); // -> a\\ b, you can't
Activity
JounQin commentedon Dec 26, 2024
I tried to add space pattern into https://github.com/webpack-contrib/css-loader/blob/9dd19662bd2df289b75283ebf277d1875bbe5089/src/utils.js#L263 and then it works as expected, I'd raise a PR if it is accepted.
JounQin commentedon Dec 26, 2024
Not sure if #997 related.
JounQin commentedon Jan 13, 2025
@alexander-akait Any time to take a look?
alexander-akait commentedon Feb 4, 2025
Yeah, technically we have CSS.escape to escape special character before inserting them in JS and it works good for non space characters, but there are some limitation with the
classattributeBut https://html.spec.whatwg.org/multipage/dom.html#global-attributes:classes-2
Let's fix it
JounQin commentedon Apr 15, 2025
@alexander-akait I don't know how to add a test case for it easily, or we just change the
filenameReservedRegex?alexander-akait commentedon Apr 16, 2025
@JounQin I think we can change
filenameReservedRegexand look at our tests, if we don't broken anything we can merge and do a patch releaseJounQin commentedon Apr 16, 2025
@alexander-akait Here we go #1632