ensure BlockStatement when we're going to be pushing nodes
This commit is contained in:
parent
83487f22a7
commit
fd2187b37d
@ -79,6 +79,8 @@ exports.ForOfStatement = function (node, parent, opts, generateUid) {
|
||||
|
||||
push(declar.kind, nodes, pattern, key);
|
||||
|
||||
util.ensureBlock(node);
|
||||
|
||||
var block = node.body;
|
||||
block.body = nodes.concat(block.body);
|
||||
};
|
||||
|
||||
@ -20,6 +20,8 @@ exports.ForOfStatement = function (node, parent, opts, generateUid) {
|
||||
KEY: key
|
||||
});
|
||||
|
||||
util.ensureBlock(node);
|
||||
|
||||
var block = node2.body;
|
||||
block.body = block.body.concat(node.body.body || []);
|
||||
|
||||
|
||||
@ -41,6 +41,13 @@ exports.parse = function (filename, code, callback, opts) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.ensureBlock = function (node) {
|
||||
var block = node.body;
|
||||
if (block.type === "BlockStatement") return;
|
||||
|
||||
node.body = [node.body];
|
||||
};
|
||||
|
||||
exports.isPattern = function (node) {
|
||||
return node.type === "ArrayPattern" || node.type === "ObjectPattern";
|
||||
};
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into vanilla ES5 with source maps and no runtime",
|
||||
"version": "1.5.4",
|
||||
"version": "1.5.5",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/sebmck/6to5",
|
||||
"repository": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user