File tree 2 files changed +5
-2
lines changed
2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 1
1
var React = require ( 'react' ) ;
2
2
var hyphenPatternRegex = / - ( [ a - z ] ) / g;
3
+ var CUSTOM_PROPERTY_OR_NO_HYPHEN_REGEX = / ^ - - [ a - z A - Z - ] + $ | ^ [ ^ - ] + $ / ;
3
4
4
5
/**
5
6
* Converts a string to camelCase.
@@ -12,8 +13,8 @@ function camelCase(string) {
12
13
throw new TypeError ( 'First argument must be a string' ) ;
13
14
}
14
15
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 ) ) {
17
18
return string ;
18
19
}
19
20
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ describe('utilties.camelCase', () => {
20
20
assert . equal ( camelCase ( '' ) , '' ) ;
21
21
assert . equal ( camelCase ( 'foo' ) , 'foo' ) ;
22
22
assert . equal ( camelCase ( 'fooBar' ) , 'fooBar' ) ;
23
+ assert . equal ( camelCase ( '--fooBar' ) , '--fooBar' ) ;
24
+ assert . equal ( camelCase ( '--foo-bar' ) , '--foo-bar' ) ;
23
25
} ) ;
24
26
25
27
it ( 'camelCases a string' , ( ) => {
You can’t perform that action at this time.
0 commit comments