@@ -286,14 +286,16 @@ describe('Expression Parser', function () {
286
286
expect ( res1 ) . toBe ( res2 )
287
287
} )
288
288
289
- it ( 'ES2015 template string handling' , function ( ) {
290
- var res = expParser . parseExpression ( 'a + `hi ${ b }` + c' )
291
- expect ( res . get . toString ( ) . indexOf ( 'scope.a+`hi ${scope.b}`+scope.c' ) > - 1 ) . toBe ( true )
292
- res = expParser . parseExpression ( '`hi ${ b + `${ d }` }`' )
293
- expect ( res . get . toString ( ) . indexOf ( '`hi ${scope.b+`${scope.d}`}`' ) > - 1 ) . toBe ( true )
294
- res = expParser . parseExpression ( '{transform:`rotate(${x}deg)`}' )
295
- expect ( res . get . toString ( ) . indexOf ( '{transform:`rotate(${scope.x}deg)`}' ) > - 1 ) . toBe ( true )
296
- } )
289
+ if ( canMakeTemplateStringFunction ( ) ) {
290
+ it ( 'ES2015 template string handling' , function ( ) {
291
+ var res = expParser . parseExpression ( 'a + `hi ${ b }` + c' )
292
+ expect ( res . get . toString ( ) . indexOf ( 'scope.a+`hi ${scope.b}`+scope.c' ) > - 1 ) . toBe ( true )
293
+ res = expParser . parseExpression ( '`hi ${ b + `${ d }` }`' )
294
+ expect ( res . get . toString ( ) . indexOf ( '`hi ${scope.b+`${scope.d}`}`' ) > - 1 ) . toBe ( true )
295
+ res = expParser . parseExpression ( '{transform:`rotate(${x}deg)`}' )
296
+ expect ( res . get . toString ( ) . indexOf ( '{transform:`rotate(${scope.x}deg)`}' ) > - 1 ) . toBe ( true )
297
+ } )
298
+ }
297
299
298
300
describe ( 'invalid expression' , function ( ) {
299
301
beforeEach ( function ( ) {
@@ -319,3 +321,13 @@ describe('Expression Parser', function () {
319
321
} )
320
322
} )
321
323
} )
324
+
325
+ function canMakeTemplateStringFunction ( ) {
326
+ try {
327
+ /* eslint-disable no-new-func */
328
+ new Function ( 'a' , 'return `${a}`')
329
+ } catch ( e ) {
330
+ return false
331
+ }
332
+ return true
333
+ }
0 commit comments