Skip to content

Commit 2c0a9dc

Browse files
committed
feat(utilities): add support for custom styles beginning with "--*"
1 parent 1017b25 commit 2c0a9dc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/utilities.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var React = require('react');
22
var hyphenPatternRegex = /-([a-z])/g;
3+
var CUSTOM_PROPERTY_OR_NO_HYPHEN_REGEX = /^--[a-zA-Z-]+$|^[^-]+$/;
34

45
/**
56
* Converts a string to camelCase.
@@ -12,8 +13,8 @@ function camelCase(string) {
1213
throw new TypeError('First argument must be a string');
1314
}
1415

15-
// no hyphen found
16-
if (string.indexOf('-') === -1) {
16+
// custom property or no hyphen found
17+
if (CUSTOM_PROPERTY_OR_NO_HYPHEN_REGEX.test(string)) {
1718
return string;
1819
}
1920

test/utilities.js

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ describe('utilties.camelCase', () => {
2020
assert.equal(camelCase(''), '');
2121
assert.equal(camelCase('foo'), 'foo');
2222
assert.equal(camelCase('fooBar'), 'fooBar');
23+
assert.equal(camelCase('--fooBar'), '--fooBar');
24+
assert.equal(camelCase('--foo-bar'), '--foo-bar');
2325
});
2426

2527
it('camelCases a string', () => {

0 commit comments

Comments
 (0)