actually push for left declaration to the returned block scoping body - fixes #1819
This commit is contained in:
parent
cf38210fd2
commit
6f862a4c45
@ -149,25 +149,30 @@ var letReferenceFunctionVisitor = {
|
||||
};
|
||||
|
||||
var hoistVarDeclarationsVisitor = {
|
||||
enter(node, parent, scope, self) {
|
||||
if (this.isForStatement()) {
|
||||
if (isVar(node.init, node)) {
|
||||
var nodes = self.pushDeclar(node.init);
|
||||
if (nodes.length === 1) {
|
||||
node.init = nodes[0];
|
||||
} else {
|
||||
node.init = t.sequenceExpression(nodes);
|
||||
}
|
||||
VariableDeclaration(node, parent, scope, self) {
|
||||
return self.pushDeclar(node).map(t.expressionStatement);
|
||||
},
|
||||
|
||||
ForStatement(node, parent, scope, self) {
|
||||
if (isVar(node.init, node)) {
|
||||
var nodes = self.pushDeclar(node.init);
|
||||
if (nodes.length === 1) {
|
||||
node.init = nodes[0];
|
||||
} else {
|
||||
node.init = t.sequenceExpression(nodes);
|
||||
}
|
||||
} else if (this.isFor()) {
|
||||
if (isVar(node.left, node)) {
|
||||
node.left = node.left.declarations[0].id;
|
||||
}
|
||||
} else if (isVar(node, parent)) {
|
||||
return self.pushDeclar(node).map(t.expressionStatement);
|
||||
} else if (this.isFunction()) {
|
||||
return this.skip();
|
||||
}
|
||||
},
|
||||
|
||||
For(node, parent, scope, self) {
|
||||
if (isVar(node.left, node)) {
|
||||
self.pushDeclar(node.left);
|
||||
node.left = node.left.declarations[0].id;
|
||||
}
|
||||
},
|
||||
|
||||
Function() {
|
||||
this.skip();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user