File tree Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -158,10 +158,10 @@ describe('getLiteralPropValue', () => {
158
158
assert . equal ( expected , actual ) ;
159
159
} ) ;
160
160
161
- it ( 'should drop variables in template literals that are literally undefined' , ( ) => {
161
+ it ( 'should return string "undefined" for expressions that evaluate to undefined' , ( ) => {
162
162
const prop = extractProp ( '<div foo={`bar ${undefined}`} />' ) ;
163
163
164
- const expected = 'bar ' ;
164
+ const expected = 'bar undefined ' ;
165
165
const actual = getLiteralPropValue ( prop ) ;
166
166
167
167
assert . equal ( expected , actual ) ;
@@ -178,10 +178,10 @@ describe('getLiteralPropValue', () => {
178
178
assert . equal ( expected , actual ) ;
179
179
} ) ;
180
180
181
- it ( 'should drop variables in template literals that are literally undefined' , ( ) => {
181
+ it ( 'should return string "undefined" for expressions that evaluate to undefined' , ( ) => {
182
182
const prop = extractProp ( '<div foo={noop`bar ${undefined}`} />' ) ;
183
183
184
- const expected = 'bar ' ;
184
+ const expected = 'bar undefined ' ;
185
185
const actual = getLiteralPropValue ( prop ) ;
186
186
187
187
assert . equal ( expected , actual ) ;
Original file line number Diff line number Diff line change @@ -194,10 +194,10 @@ describe('getPropValue', () => {
194
194
assert . equal ( expected , actual ) ;
195
195
} ) ;
196
196
197
- it ( 'should drop variables in template literals that are literally undefined' , ( ) => {
197
+ it ( 'should return string "undefined" for expressions that evaluate to undefined' , ( ) => {
198
198
const prop = extractProp ( '<div foo={`bar ${undefined}`} />' ) ;
199
199
200
- const expected = 'bar ' ;
200
+ const expected = 'bar undefined ' ;
201
201
const actual = getPropValue ( prop ) ;
202
202
203
203
assert . equal ( expected , actual ) ;
@@ -232,10 +232,10 @@ describe('getPropValue', () => {
232
232
assert . equal ( expected , actual ) ;
233
233
} ) ;
234
234
235
- it ( 'should drop variables in template literals that are literally undefined' , ( ) => {
235
+ it ( 'should return string "undefined" for expressions that evaluate to undefined' , ( ) => {
236
236
const prop = extractProp ( '<div foo={noop`bar ${undefined}`} />' ) ;
237
237
238
- const expected = 'bar ' ;
238
+ const expected = 'bar undefined ' ;
239
239
const actual = getPropValue ( prop ) ;
240
240
241
241
assert . equal ( expected , actual ) ;
Original file line number Diff line number Diff line change 4
4
* prop. For instance `This is a ${prop}` will return 'This is a {prop}'.
5
5
*
6
6
* If the template literal builds to undefined (`${undefined}`), then
7
- * this should return "".
7
+ * this should return "undefined ".
8
8
*/
9
9
export default function extractValueFromTemplateLiteral ( value ) {
10
10
const {
@@ -20,7 +20,7 @@ export default function extractValueFromTemplateLiteral(value) {
20
20
if ( type === 'TemplateElement' ) {
21
21
return raw + part . value . raw ;
22
22
} else if ( type === 'Identifier' ) {
23
- return part . name === 'undefined' ? raw : `${ raw } {${ part . name } }` ;
23
+ return part . name === 'undefined' ? ` ${ raw } ${ part . name } ` : `${ raw } {${ part . name } }` ;
24
24
} else if ( type . indexOf ( 'Expression' ) > - 1 ) {
25
25
return `${ raw } {${ type } }` ;
26
26
}
You can’t perform that action at this time.
0 commit comments