fix rest parameters in arrow functions containing wrong arguments reference - fixes #11
This commit is contained in:
@@ -35,6 +35,8 @@ var go = function (getBody, node, file) {
|
||||
}
|
||||
}
|
||||
|
||||
if (node._ignoreAliasFunctions) return;
|
||||
|
||||
var getId;
|
||||
|
||||
if (node.type === "Identifier" && node.name === "arguments") {
|
||||
|
||||
@@ -11,9 +11,14 @@ exports.Function = function (node, parent, file) {
|
||||
if (node.params.length) templateName += "-arg";
|
||||
|
||||
util.ensureBlock(node);
|
||||
node.body.body.unshift(util.template(templateName, {
|
||||
|
||||
var template = util.template(templateName, {
|
||||
SLICE_KEY: file.addDeclaration("slice"),
|
||||
VARIABLE_NAME: rest,
|
||||
SLICE_ARG: b.literal(node.params.length)
|
||||
}));
|
||||
});
|
||||
|
||||
template.declarations[0].init.arguments[0]._ignoreAliasFunctions = true;
|
||||
|
||||
node.body.body.unshift(template);
|
||||
};
|
||||
|
||||
3
test/fixtures/transformation/rest-parameters/arrow-functions/actual.js
vendored
Normal file
3
test/fixtures/transformation/rest-parameters/arrow-functions/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var concat = (...arrs) => {
|
||||
|
||||
};
|
||||
5
test/fixtures/transformation/rest-parameters/arrow-functions/expected.js
vendored
Normal file
5
test/fixtures/transformation/rest-parameters/arrow-functions/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
var _slice = Array.prototype.slice;
|
||||
var concat = function () {
|
||||
var arrs = _slice.call(arguments);
|
||||
};
|
||||
Reference in New Issue
Block a user