@@ -1624,12 +1624,41 @@ 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
+ // eslint-disable-next-line no-eval
1639
+ return ( 0 , eval ) (
1640
+ '({' + JSON . stringify ( name ) + ':async function(){}})' ,
1641
+ ) [ name ] ;
1642
+ }
1643
+ } else if ( code . startsWith ( '(function' ) ) {
1644
+ const idx = code . indexOf ( '(' , 9 ) ;
1645
+ if ( idx !== - 1 ) {
1646
+ const name = code . slice ( 9 , idx ) . trim ( ) ;
1647
+ // eslint-disable-next-line no-eval
1648
+ return ( 0 , eval ) (
1649
+ '({' + JSON . stringify ( name ) + ':function(){}})' ,
1650
+ ) [ name ] ;
1651
+ }
1652
+ } else if ( code . startsWith ( '(class' ) ) {
1653
+ const idx = code . indexOf ( '{' , 6 ) ;
1654
+ if ( idx !== - 1 ) {
1655
+ const name = code . slice ( 6 , idx ) . trim ( ) ;
1656
+ // eslint-disable-next-line no-eval
1657
+ return ( 0 , eval ) ( '({' + JSON . stringify ( name ) + ':class{}})' ) [
1658
+ name
1659
+ ] ;
1660
+ }
1661
+ }
1633
1662
return function ( ) { } ;
1634
1663
}
1635
1664
}
0 commit comments