diff --git a/README.md b/README.md index d325b41181..c62ac45f67 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

- Travis Status + Travis Status diff --git a/lib/6to5/transformers/destructuring.js b/lib/6to5/transformers/destructuring.js index a214b6c5ba..792c4b32c6 100644 --- a/lib/6to5/transformers/destructuring.js +++ b/lib/6to5/transformers/destructuring.js @@ -147,5 +147,22 @@ exports.VariableDeclaration = function (node, parent, file) { } }); + if (parent.type !== "Program" && parent.type !== "BlockStatement") { + var declar; + + _.each(nodes, function (node) { + declar = declar || b.variableDeclaration(node.kind, []); + + if (node.type !== "VariableDeclaration" && declar.kind !== node.kind) { + throw util.errorWithNode(node, "Cannot use this node within the current parent"); + } + + declar.declarations = declar.declarations.concat(node.declarations); + }); + + return declar; + } + return nodes; }; + diff --git a/package.json b/package.json index e7ac67a1bb..7190db3349 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "6to5", "description": "Turn ES6 code into readable vanilla ES5 with source maps", - "version": "1.10.8", + "version": "1.10.9", "author": "Sebastian McKenzie ", "homepage": "https://github.com/sebmck/6to5", "repository": {