fix spread not returning a new array with a single spread element
This commit is contained in:
parent
1de4893a69
commit
3396cc84f1
@ -1,3 +1,7 @@
|
||||
# 1.13.4
|
||||
|
||||
* Fix single spread element returning itself.
|
||||
|
||||
# 1.13.3
|
||||
|
||||
* Upgrade `acorn-6to5`.
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -4,4 +4,4 @@ var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var lyrics = _toArray(parts).concat(["head", "and", "toes"]);
|
||||
var lyrics = [].concat(_toArray(parts), ["head", "and", "toes"]);
|
||||
|
||||
@ -4,4 +4,4 @@ var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
_toArray(foo);
|
||||
[].concat(_toArray(foo));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user