fix block scoped functions
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
var t = require("../../../types");
|
||||
|
||||
exports.BlockStatement = function (node, parent) {
|
||||
if (t.isFunction(parent) || t.isExportDeclaration(parent)) {
|
||||
if ((t.isFunction(parent) && parent.body === node) || t.isExportDeclaration(parent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < node.body.length; i++) {
|
||||
var func = node.body[i];
|
||||
if (!t.isFunctionDeclaration(i)) continue;
|
||||
if (!t.isFunctionDeclaration(func)) continue;
|
||||
|
||||
var declar = t.variableDeclaration("let", [
|
||||
t.variableDeclarator(func.id, t.toExpression(func))
|
||||
@@ -21,6 +21,6 @@ exports.BlockStatement = function (node, parent) {
|
||||
// todo: name this
|
||||
func.id = null;
|
||||
|
||||
func.body[i] = declar;
|
||||
node.body[i] = declar;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user