File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -1819,9 +1819,19 @@ if (typeof J$ === 'undefined') {
18191819 }
18201820 }
18211821 for ( var i = startIndex ; i < ast . body . length ; i ++ ) {
1822-
18231822 if ( ast . body [ i ] . type === 'FunctionDeclaration' ) {
1824- newBody . push ( ast . body [ i ] ) ;
1823+ var name = ast . body [ i ] . id . name ;
1824+ var params = ast . body [ i ] . params . map ( function ( param ) { return param . name ; } ) . join ( ', ' ) ;
1825+ var assignStmt ;
1826+ if ( ast . body [ i ] . body === null ) {
1827+ assignStmt = acorn . parse (
1828+ "var " + name + " = function " + name + "(" + params + ") {}" ) . body ;
1829+ } else {
1830+ assignStmt = replaceInStatement (
1831+ "var " + name + " = function " + name + "(" + params + ") { " + RP + "1 }" ,
1832+ ast . body [ i ] . body . body ) ;
1833+ }
1834+ newBody . push ( assignStmt [ 0 ] ) ;
18251835 if ( newBody . length !== i + 1 ) {
18261836 hoisteredFunctions . push ( ast . body [ i ] . id . name ) ;
18271837 }
@@ -1835,9 +1845,7 @@ if (typeof J$ === 'undefined') {
18351845 while ( ast . body . length > 0 ) {
18361846 ast . body . pop ( ) ;
18371847 }
1838- for ( var i = 0 ; i < newBody . length ; i ++ ) {
1839- ast . body . push ( newBody [ i ] ) ;
1840- }
1848+ Array . prototype . push . apply ( ast . body , newBody ) ;
18411849 } else {
18421850 //console.log(typeof ast.body);
18431851 }
You can’t perform that action at this time.
0 commit comments