Skip to content

Commit 1f26283

Browse files
Merge pull request #83 from samikarak/master
support custom styles beginning with '--*'
2 parents 185d2f2 + 2c0a9dc commit 1f26283

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/utilities.js

Lines changed: 3 additions & 2 deletions
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

Lines changed: 2 additions & 0 deletions
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)