Skip to content

Commit 1fee601

Browse files
sanpoChewmichael-ciniawsky
authored andcommitted
fix: match mutliple dashes (options.camelCase) (#556)
1 parent c13c467 commit 1fee601

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/compile-exports.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var camelCase = require("lodash.camelcase");
22

33
function dashesCamelCase(str) {
4-
return str.replace(/-(\w)/g, function(match, firstLetter) {
4+
return str.replace(/-+(\w)/g, function(match, firstLetter) {
55
return firstLetter.toUpperCase();
66
});
77
}

test/camelCaseTest.js

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var testRaw = require("./helpers").testRaw;
55

66
describe("camelCase", function() {
77
var css = ".btn-info_is-disabled { color: blue; }";
8+
var cssMultipleDashes = ".btn--info_is-disabled { color: blue; }";
89
var mixedCss = ".btn-info_is-disabled { color: blue; } .simple { color: red; }";
910
var exports = {
1011
with: [
@@ -16,6 +17,9 @@ describe("camelCase", function() {
1617
dashes: [
1718
[1, "._1L-rnCOXCE_7H94L5XT4uB { color: blue; }", ""]
1819
],
20+
multipleDashes: [
21+
[1, "._3JUlsKrl__OF70Fq391jEw { color: blue; }", ""]
22+
],
1923
withoutOnly: [
2024
[1, "._1L-rnCOXCE_7H94L5XT4uB { color: blue; } .KKtodWG-IuEaequFjAsoJ { color: red; }", ""]
2125
],
@@ -26,11 +30,13 @@ describe("camelCase", function() {
2630
exports.with.locals = {'btn-info_is-disabled': '_1L-rnCOXCE_7H94L5XT4uB'};
2731
exports.without.locals = {btnInfoIsDisabled: '_1L-rnCOXCE_7H94L5XT4uB', 'btn-info_is-disabled': '_1L-rnCOXCE_7H94L5XT4uB'};
2832
exports.dashes.locals = {btnInfo_isDisabled: '_1L-rnCOXCE_7H94L5XT4uB', 'btn-info_is-disabled': '_1L-rnCOXCE_7H94L5XT4uB'};
33+
exports.multipleDashes.locals = {btnInfo_isDisabled: '_3JUlsKrl__OF70Fq391jEw', 'btn--info_is-disabled': '_3JUlsKrl__OF70Fq391jEw'};
2934
exports.withoutOnly.locals = {btnInfoIsDisabled: '_1L-rnCOXCE_7H94L5XT4uB', simple: 'KKtodWG-IuEaequFjAsoJ'};
3035
exports.dashesOnly.locals = {btnInfo_isDisabled: '_1L-rnCOXCE_7H94L5XT4uB', simple: 'KKtodWG-IuEaequFjAsoJ'};
3136
test("with", css, exports.with, "?modules");
3237
test("without", css, exports.without, "?modules&camelCase");
3338
test("dashes", css, exports.dashes, "?modules&camelCase=dashes");
39+
test("multipleDashes", cssMultipleDashes, exports.multipleDashes, "?modules&camelCase=dashes");
3440
// Remove this option in v1.0.0 and make the removal of the original classname the default behaviour. See #440.
3541
test("withoutOnly", mixedCss, exports.withoutOnly, "?modules&camelCase=only");
3642
// Remove this option in v1.0.0 and make the removal of the original classname the default behaviour. See #440.

0 commit comments

Comments
 (0)