@@ -1636,12 +1636,41 @@ function parseModelString(
16361636 if ( __DEV__ ) {
16371637 // In DEV mode we allow indirect eval to produce functions for logging.
16381638 // This should not compile to eval() because then it has local scope access.
1639+ const code = value . slice ( 2 ) ;
16391640 try {
16401641 // eslint-disable-next-line no-eval
1641- return ( 0 , eval ) ( value . slice ( 2 ) ) ;
1642+ return ( 0 , eval ) ( code ) ;
16421643 } catch ( x ) {
16431644 // We currently use this to express functions so we fail parsing it,
16441645 // 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+ }
16451674 return function ( ) { } ;
16461675 }
16471676 }
0 commit comments