Skip to content
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

fix: match mutliple dashes (options.camelCase) #556

Merged
merged 3 commits into from Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/compile-exports.js
@@ -1,7 +1,7 @@
var camelCase = require("lodash.camelcase");

function dashesCamelCase(str) {
return str.replace(/-(\w)/g, function(match, firstLetter) {
return str.replace(/-+(\w)/g, function(match, firstLetter) {
return firstLetter.toUpperCase();
});
}
Expand Down
6 changes: 6 additions & 0 deletions test/camelCaseTest.js
Expand Up @@ -5,6 +5,7 @@ var testRaw = require("./helpers").testRaw;

describe("camelCase", function() {
var css = ".btn-info_is-disabled { color: blue; }";
var cssMultipleDashes = ".btn--info_is-disabled { color: blue; }";
var mixedCss = ".btn-info_is-disabled { color: blue; } .simple { color: red; }";
var exports = {
with: [
Expand All @@ -16,6 +17,9 @@ describe("camelCase", function() {
dashes: [
[1, "._1L-rnCOXCE_7H94L5XT4uB { color: blue; }", ""]
],
multipleDashes: [
[1, "._3JUlsKrl__OF70Fq391jEw { color: blue; }", ""]
],
withoutOnly: [
[1, "._1L-rnCOXCE_7H94L5XT4uB { color: blue; } .KKtodWG-IuEaequFjAsoJ { color: red; }", ""]
],
Expand All @@ -26,11 +30,13 @@ describe("camelCase", function() {
exports.with.locals = {'btn-info_is-disabled': '_1L-rnCOXCE_7H94L5XT4uB'};
exports.without.locals = {btnInfoIsDisabled: '_1L-rnCOXCE_7H94L5XT4uB', 'btn-info_is-disabled': '_1L-rnCOXCE_7H94L5XT4uB'};
exports.dashes.locals = {btnInfo_isDisabled: '_1L-rnCOXCE_7H94L5XT4uB', 'btn-info_is-disabled': '_1L-rnCOXCE_7H94L5XT4uB'};
exports.multipleDashes.locals = {btnInfo_isDisabled: '_3JUlsKrl__OF70Fq391jEw', 'btn--info_is-disabled': '_3JUlsKrl__OF70Fq391jEw'};
exports.withoutOnly.locals = {btnInfoIsDisabled: '_1L-rnCOXCE_7H94L5XT4uB', simple: 'KKtodWG-IuEaequFjAsoJ'};
exports.dashesOnly.locals = {btnInfo_isDisabled: '_1L-rnCOXCE_7H94L5XT4uB', simple: 'KKtodWG-IuEaequFjAsoJ'};
test("with", css, exports.with, "?modules");
test("without", css, exports.without, "?modules&camelCase");
test("dashes", css, exports.dashes, "?modules&camelCase=dashes");
test("multipleDashes", cssMultipleDashes, exports.multipleDashes, "?modules&camelCase=dashes");
// Remove this option in v1.0.0 and make the removal of the original classname the default behaviour. See #440.
test("withoutOnly", mixedCss, exports.withoutOnly, "?modules&camelCase=only");
// Remove this option in v1.0.0 and make the removal of the original classname the default behaviour. See #440.
Expand Down