Skip to content

Commit a2f1ada

Browse files
committed
Merge pull request webpack-contrib#96 from rtsao/fix-class-names
Fix broken composition with class names that contain characters other than [A-Za-z0-9_]
2 parents 06fb990 + 1987647 commit a2f1ada

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/processCss.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
2020
var urlItems = [];
2121

2222
function replaceImportsInString(str) {
23-
var tokens = str.split(/(\w+)/);
23+
var tokens = str.split(/(\S+)/);
2424
tokens = tokens.map(function(token) {
2525
var importIndex = imports["$" + token];
2626
if(typeof importIndex === "number") {

test/localTest.js

+27
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,33 @@ describe("local", function() {
9696
return r;
9797
}())
9898
});
99+
testLocal("composes class with hyphen from module", [
100+
":local(.c1) { composes: c-2 from \"./module\"; b: 1; }",
101+
":local(.c3) { composes: c1; b: 3; }",
102+
":local(.c5) { composes: c-2 c4 from \"./module\"; b: 5; }"
103+
].join("\n"), [
104+
[2, ".test{c: d}", ""],
105+
[1, [
106+
"._c1 { b: 1; }",
107+
"._c3 { b: 3; }",
108+
"._c5 { b: 5; }"
109+
].join("\n"), ""]
110+
], {
111+
c1: "_c1 imported-c-2",
112+
c3: "_c3 _c1 imported-c-2",
113+
c5: "_c5 imported-c-2 imported-c4"
114+
}, "?localIdentName=_[local]", {
115+
"./module": (function() {
116+
var r = [
117+
[2, ".test{c: d}", ""]
118+
];
119+
r.locals = {
120+
"c-2": "imported-c-2",
121+
c4: "imported-c4"
122+
};
123+
return r;
124+
}())
125+
});
99126
testLocal("composes class from module with import", [
100127
"@import url(\"module\");",
101128
":local(.c1) { composes: c2 c3 from \"./module\"; composes: c4 from \"./module\"; b: 1; }"

0 commit comments

Comments
 (0)