diff --git a/lib/6to5/transformers/_alias-functions.js b/lib/6to5/transformers/_alias-functions.js index 18615572fd..d1435f47c2 100644 --- a/lib/6to5/transformers/_alias-functions.js +++ b/lib/6to5/transformers/_alias-functions.js @@ -35,6 +35,8 @@ var go = function (getBody, node, file) { } } + if (node._ignoreAliasFunctions) return; + var getId; if (node.type === "Identifier" && node.name === "arguments") { diff --git a/lib/6to5/transformers/rest-parameters.js b/lib/6to5/transformers/rest-parameters.js index 1090f4fde3..7f020a79f0 100644 --- a/lib/6to5/transformers/rest-parameters.js +++ b/lib/6to5/transformers/rest-parameters.js @@ -12,9 +12,14 @@ exports.Function = function (node, parent, file) { if (node.params.length) templateName += "-arg"; t.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); }; diff --git a/package.json b/package.json index 823cb6f1b2..6217560ce5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "6to5", "description": "Turn ES6 code into readable vanilla ES5 with source maps", - "version": "1.10.7", + "version": "1.10.8", "author": "Sebastian McKenzie ", "homepage": "https://github.com/sebmck/6to5", "repository": { diff --git a/test/fixtures/transformation/rest-parameters/arrow-functions/actual.js b/test/fixtures/transformation/rest-parameters/arrow-functions/actual.js new file mode 100644 index 0000000000..4a130fad8d --- /dev/null +++ b/test/fixtures/transformation/rest-parameters/arrow-functions/actual.js @@ -0,0 +1,3 @@ +var concat = (...arrs) => { + +}; diff --git a/test/fixtures/transformation/rest-parameters/arrow-functions/expected.js b/test/fixtures/transformation/rest-parameters/arrow-functions/expected.js new file mode 100644 index 0000000000..ede93ea6e7 --- /dev/null +++ b/test/fixtures/transformation/rest-parameters/arrow-functions/expected.js @@ -0,0 +1,5 @@ +"use strict"; +var _slice = Array.prototype.slice; +var concat = function () { + var arrs = _slice.call(arguments); +};