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