File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ const TokenStream = require('./TokenStream');
7
7
// Note if this is wrong, you'll need to change tokenTypes.js too
8
8
const numberOrLengthRe = / ^ ( [ + - ] ? (?: \d * \. ) ? \d + (?: [ E e ] [ + - ] ? \d + ) ? ) (?: p x ) ? $ / i;
9
9
const boolRe = / ^ t r u e | f a l s e $ / i;
10
+ const nullRe = / ^ n u l l $ / i;
11
+ const undefinedRe = / ^ u n d e f i n e d $ / i;
10
12
11
13
// Undocumented export
12
14
export const transformRawValue = ( input ) => {
@@ -18,6 +20,12 @@ export const transformRawValue = (input) => {
18
20
const boolMatch = input . match ( boolRe ) ;
19
21
if ( boolMatch !== null ) return boolMatch [ 0 ] . toLowerCase ( ) === 'true' ;
20
22
23
+ const nullMatch = input . match ( nullRe ) ;
24
+ if ( nullMatch !== null ) return null ;
25
+
26
+ const undefinedMatch = input . match ( undefinedRe ) ;
27
+ if ( undefinedMatch !== null ) return undefined ;
28
+
21
29
return value ;
22
30
} ;
23
31
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ it('allows pixels in unspecialized transform', () => runTest([
17
17
[ 'top' , '0px' ] ,
18
18
] , { top : 0 } ) ) ;
19
19
20
- it ( 'allows boolean values values ' , ( ) => runTest ( [
20
+ it ( 'allows boolean values' , ( ) => runTest ( [
21
21
[ 'boolTrue1' , 'true' ] ,
22
22
[ 'boolTrue2' , 'TRUE' ] ,
23
23
[ 'boolFalse1' , 'false' ] ,
@@ -29,6 +29,22 @@ it('allows boolean values values', () => runTest([
29
29
boolFalse2 : false ,
30
30
} ) ) ;
31
31
32
+ it ( 'allows null values' , ( ) => runTest ( [
33
+ [ 'null1' , 'null' ] ,
34
+ [ 'null2' , 'NULL' ] ,
35
+ ] , {
36
+ null1 : null ,
37
+ null2 : null ,
38
+ } ) ) ;
39
+
40
+ it ( 'allows undefined values' , ( ) => runTest ( [
41
+ [ 'undefined1' , 'undefined' ] ,
42
+ [ 'undefined2' , 'UNDEFINED' ] ,
43
+ ] , {
44
+ undefined1 : undefined ,
45
+ undefined2 : undefined ,
46
+ } ) ) ;
47
+
32
48
it ( 'allows percent in unspecialized transform' , ( ) => runTest ( [
33
49
[ 'top' , '0%' ] ,
34
50
] , { top : '0%' } ) ) ;
You can’t perform that action at this time.
0 commit comments