switch block scoping for in/of var hoisting statements - fixes #2174
This commit is contained in:
parent
68d750120a
commit
aba44e38b7
@ -233,8 +233,8 @@ var hoistVarDeclarationsVisitor = {
|
||||
}
|
||||
} else if (this.isFor()) {
|
||||
if (isVar(node.left, node)) {
|
||||
node.left = node.left.declarations[0].id;
|
||||
self.pushDeclar(node.left);
|
||||
node.left = node.left.declarations[0].id;
|
||||
}
|
||||
} else if (isVar(node, parent)) {
|
||||
return self.pushDeclar(node).map(t.expressionStatement);
|
||||
|
||||
7
packages/babel/test/fixtures/transformation/es6.block-scoping/issue-2174/actual.js
vendored
Normal file
7
packages/babel/test/fixtures/transformation/es6.block-scoping/issue-2174/actual.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
if (true) {
|
||||
function foo() {}
|
||||
function bar() {
|
||||
return foo;
|
||||
}
|
||||
for (var x in {}) {}
|
||||
}
|
||||
15
packages/babel/test/fixtures/transformation/es6.block-scoping/issue-2174/expected.js
vendored
Normal file
15
packages/babel/test/fixtures/transformation/es6.block-scoping/issue-2174/expected.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
if (true) {
|
||||
var x;
|
||||
|
||||
(function () {
|
||||
var foo = function foo() {};
|
||||
|
||||
var bar = function bar() {
|
||||
return foo;
|
||||
};
|
||||
|
||||
for (x in {}) {}
|
||||
})();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user