properly hoist all var patterns when wrapping bodies in the es6.blockScoping transformer - fixes #1521
This commit is contained in:
@@ -13,6 +13,11 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
|
||||
## 5.3.2
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix patterns not being considered when hoisting variables in the `es6.blockScoping` transformer.
|
||||
|
||||
## 5.3.1
|
||||
|
||||
* **Bug Fix**
|
||||
|
||||
@@ -557,9 +557,13 @@ class BlockScoping {
|
||||
*/
|
||||
|
||||
pushDeclar(node: { type: "VariableDeclaration" }): Array<Object> {
|
||||
this.body.push(t.variableDeclaration(node.kind, node.declarations.map(function (declar) {
|
||||
return t.variableDeclarator(declar.id);
|
||||
})));
|
||||
var declars = [];
|
||||
var names = t.getBindingIdentifiers(node);
|
||||
for (var name in names) {
|
||||
declars.push(t.variableDeclarator(names[name]));
|
||||
}
|
||||
|
||||
this.body.push(t.variableDeclaration(node.kind, declars));
|
||||
|
||||
var replace = [];
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ export function VariableDeclaration(node, parent, scope, file) {
|
||||
file: file
|
||||
});
|
||||
|
||||
if (t.isPattern(pattern) && patternId) {
|
||||
if (t.isPattern(pattern)) {
|
||||
destructuring.init(pattern, patternId);
|
||||
|
||||
if (+i !== node.declarations.length - 1) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
for (let i of nums) {
|
||||
var x = 5;
|
||||
var { f } = { f: 2 };
|
||||
fns.push(function () {
|
||||
return i * x;
|
||||
});
|
||||
|
||||
@@ -8,6 +8,8 @@ try {
|
||||
var _loop = function () {
|
||||
var i = _step.value;
|
||||
x = 5;
|
||||
var _f = { f: 2 };
|
||||
f = _f.f;
|
||||
|
||||
fns.push(function () {
|
||||
return i * x;
|
||||
@@ -16,6 +18,7 @@ try {
|
||||
|
||||
for (var _iterator = nums[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var x;
|
||||
var f;
|
||||
|
||||
_loop();
|
||||
}
|
||||
@@ -32,4 +35,4 @@ try {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user