fix spread not returning a new array with a single spread element

This commit is contained in:
Sebastian McKenzie
2014-11-23 20:16:10 +11:00
parent 1de4893a69
commit 3396cc84f1
4 changed files with 10 additions and 3 deletions

View File

@@ -48,7 +48,10 @@ exports.ArrayExpression = function (node, parent, file) {
var nodes = build(elements, file);
var first = nodes.shift();
if (!nodes.length) return first;
if (!t.isArrayExpression(first)) {
nodes.unshift(first);
first = t.arrayExpression([]);
}
return t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes);
};