@@ -7,33 +7,38 @@ const getValue = value => {
77 return value . value === "" ? undefined : value . value ;
88 } else if ( value . type === 'Identifier' ) {
99 return value . name === "" ? undefined : value . name ;
10- } else if ( value . type === 'JSXExpressionContainer' ) {
11- const { expression } = value ;
12-
13- switch ( expression . type ) {
14- case 'Literal' :
15- return expression . value === "" ? undefined : expression . value ;
16- case 'TemplateLiteral' :
17- return buildTemplateLiteral ( expression ) ;
18- case 'Identifier' :
19- return expression . name == 'undefined' ? undefined : expression . name ;
20- case 'ArrowFunctionExpression' :
21- case 'FunctionExpression' :
22- return ( ) => void 0 ;
23- case 'LogicalExpression' :
24- const { operator, left, right } = expression ;
25- const leftVal = getValue ( left ) ;
26- const rightVal = getValue ( right ) ;
27-
28- return operator == '&&' ? leftVal && rightVal : leftVal || rightVal ;
29- case 'MemberExpression' :
30- return `${ getValue ( expression . object ) } .${ expression . property } ` ;
31- default :
32- return undefined ;
33- }
10+ } else if ( value . type === 'JSXElement' ) {
11+ return undefined ; // For now, just so things don't break.
12+ }
13+
14+ const { expression } = value ;
15+ const type = expression ? expression . type : value . type ;
16+ const obj = expression || value ;
17+
18+ switch ( type ) {
19+ case 'Literal' :
20+ return obj . value === "" ? undefined : obj . value ;
21+ case 'TemplateLiteral' :
22+ return buildTemplateLiteral ( obj ) ;
23+ case 'Identifier' :
24+ return obj . name == 'undefined' ? undefined : obj . name ;
25+ case 'ArrowFunctionExpression' :
26+ case 'FunctionExpression' :
27+ return ( ) => void 0 ;
28+ case 'LogicalExpression' :
29+ const { operator, left, right } = obj ;
30+ const leftVal = getValue ( left ) ;
31+ const rightVal = getValue ( right ) ;
32+
33+ return operator == '&&' ? leftVal && rightVal : leftVal || rightVal ;
34+ case 'MemberExpression' :
35+ return `${ getValue ( obj . object ) } .${ getValue ( obj . property ) } ` ;
36+ case 'CallExpression' :
37+ return getValue ( obj . callee ) ;
38+ default :
39+ return undefined ;
3440 }
3541
36- return undefined ;
3742} ;
3843
3944/**
0 commit comments