File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,20 @@ const transforms = require('./transforms');
5
5
const TokenStream = require ( './TokenStream' ) ;
6
6
7
7
// Note if this is wrong, you'll need to change tokenTypes.js too
8
- const numberOrLengthRe = / ^ ( [ + - ] ? (?: \d * \. ) ? \d + (?: [ E e ] [ + - ] ? \d + ) ? ) (?: p x ) ? $ / ;
8
+ const numberOrLengthRe = / ^ ( [ + - ] ? (?: \d * \. ) ? \d + (?: [ E e ] [ + - ] ? \d + ) ? ) (?: p x ) ? $ / i;
9
+ const boolRe = / ^ t r u e | f a l s e $ / i;
9
10
10
11
// Undocumented export
11
12
export const transformRawValue = ( input ) => {
12
- const value = input . trim ( ) . match ( numberOrLengthRe ) ;
13
- return value ? Number ( value [ 1 ] ) : input ;
13
+ const value = input . trim ( ) ;
14
+
15
+ const numberMatch = value . match ( numberOrLengthRe ) ;
16
+ if ( numberMatch ) return Number ( numberMatch [ 1 ] ) ;
17
+
18
+ const boolMatch = input . match ( boolRe ) ;
19
+ if ( boolMatch ) return boolMatch [ 0 ] . toLowerCase ( ) === 'true' ;
20
+
21
+ return value ;
14
22
} ;
15
23
16
24
export const getStylesForProperty = ( propName , inputValue , allowShorthand ) => {
You can’t perform that action at this time.
0 commit comments