Merge pull request #240 from thejameskyle/arguments-spread
Only slice arguments when necessary - fixes #239
This commit is contained in:
commit
2eab56c38b
@ -64,7 +64,12 @@ exports.CallExpression = function (node, parent, file) {
|
||||
|
||||
node.arguments = [];
|
||||
|
||||
var nodes = build(args, file);
|
||||
var nodes;
|
||||
if (args.length === 1 && args[0].argument.name === 'arguments') {
|
||||
nodes = [args[0].argument];
|
||||
} else {
|
||||
nodes = build(args, file);
|
||||
}
|
||||
var first = nodes.shift();
|
||||
|
||||
if (nodes.length) {
|
||||
|
||||
9
test/fixtures/transformation/es6-spread/arguments-array/actual.js
vendored
Normal file
9
test/fixtures/transformation/es6-spread/arguments-array/actual.js
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
function foo() {
|
||||
return bar([...arguments]);
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
return [one, two, three];
|
||||
}
|
||||
|
||||
foo("foo", "bar");
|
||||
12
test/fixtures/transformation/es6-spread/arguments-array/expected.js
vendored
Normal file
12
test/fixtures/transformation/es6-spread/arguments-array/expected.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
function foo() {
|
||||
return bar([].concat(_slice.call(arguments)));
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
return [one, two, three];
|
||||
}
|
||||
|
||||
foo("foo", "bar");
|
||||
9
test/fixtures/transformation/es6-spread/arguments-concat/actual.js
vendored
Normal file
9
test/fixtures/transformation/es6-spread/arguments-concat/actual.js
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
function foo() {
|
||||
return bar("test", ...arguments);
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
return [one, two, three];
|
||||
}
|
||||
|
||||
foo("foo", "bar");
|
||||
12
test/fixtures/transformation/es6-spread/arguments-concat/expected.js
vendored
Normal file
12
test/fixtures/transformation/es6-spread/arguments-concat/expected.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
function foo() {
|
||||
return bar.apply(null, ["test"].concat(_slice.call(arguments)));
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
return [one, two, three];
|
||||
}
|
||||
|
||||
foo("foo", "bar");
|
||||
@ -1,5 +1,5 @@
|
||||
function foo() {
|
||||
return bar("test", ...arguments);
|
||||
return bar(...arguments);
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
function foo() {
|
||||
return bar.apply(null, ["test"].concat(_slice.call(arguments)));
|
||||
return bar.apply(null, arguments);
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user