@@ -1624,12 +1624,38 @@ function parseModelString(
1624
1624
if ( __DEV__ ) {
1625
1625
// In DEV mode we allow indirect eval to produce functions for logging.
1626
1626
// This should not compile to eval() because then it has local scope access.
1627
+ const code = value . slice ( 2 ) ;
1627
1628
try {
1628
1629
// eslint-disable-next-line no-eval
1629
- return ( 0 , eval ) ( value . slice ( 2 ) ) ;
1630
+ return ( 0 , eval ) ( code ) ;
1630
1631
} catch ( x ) {
1631
1632
// We currently use this to express functions so we fail parsing it,
1632
1633
// let's just return a blank function as a place holder.
1634
+ if ( code . startsWith ( '(async function' ) ) {
1635
+ const idx = code . indexOf ( '(' , 15 ) ;
1636
+ if ( idx !== - 1 ) {
1637
+ const name = code . slice ( 15 , idx ) . trim ( ) ;
1638
+ return ( 0 , eval ) (
1639
+ '({' + JSON . stringify ( name ) + ':async function(){}})' ,
1640
+ ) [ name ] ;
1641
+ }
1642
+ } else if ( code . startsWith ( '(function' ) ) {
1643
+ const idx = code . indexOf ( '(' , 9 ) ;
1644
+ if ( idx !== - 1 ) {
1645
+ const name = code . slice ( 9 , idx ) . trim ( ) ;
1646
+ return ( 0 , eval ) (
1647
+ '({' + JSON . stringify ( name ) + ':function(){}})' ,
1648
+ ) [ name ] ;
1649
+ }
1650
+ } else if ( code . startsWith ( '(class' ) ) {
1651
+ const idx = code . indexOf ( '{' , 6 ) ;
1652
+ if ( idx !== - 1 ) {
1653
+ const name = code . slice ( 6 , idx ) . trim ( ) ;
1654
+ return ( 0 , eval ) ( '({' + JSON . stringify ( name ) + ':class{}})' ) [
1655
+ name
1656
+ ] ;
1657
+ }
1658
+ }
1633
1659
return function ( ) { } ;
1634
1660
}
1635
1661
}
0 commit comments