Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
115dca56b6 | ||
|
|
251e4d01c8 | ||
|
|
530ad78428 | ||
|
|
51f72ace57 | ||
|
|
2fa36b30d5 | ||
|
|
6f8cbf0ad1 | ||
|
|
6696d5fcf4 |
@@ -4,7 +4,7 @@
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/sebmck/6to5">
|
||||
<img alt="Travis Status" src="http://img.shields.io/travis/sebmck/6to5.svg?style=flat&label=travis">
|
||||
<img alt="Travis Status" src="http://img.shields.io/travis/sebmck/6to5.svg?branch=master&style=flat&label=travis">
|
||||
</a>
|
||||
|
||||
<a href="https://codeclimate.com/github/sebmck/6to5">
|
||||
|
||||
@@ -35,6 +35,8 @@ var go = function (getBody, node, file) {
|
||||
}
|
||||
}
|
||||
|
||||
if (node._ignoreAliasFunctions) return;
|
||||
|
||||
var getId;
|
||||
|
||||
if (node.type === "Identifier" && node.name === "arguments") {
|
||||
|
||||
@@ -148,5 +148,22 @@ exports.VariableDeclaration = function (node, parent, file) {
|
||||
}
|
||||
});
|
||||
|
||||
if (parent.type !== "Program" && parent.type !== "BlockStatement") {
|
||||
var declar;
|
||||
|
||||
_.each(nodes, function (node) {
|
||||
declar = declar || b.variableDeclaration(node.kind, []);
|
||||
|
||||
if (node.type !== "VariableDeclaration" && declar.kind !== node.kind) {
|
||||
throw util.errorWithNode(node, "Cannot use this node within the current parent");
|
||||
}
|
||||
|
||||
declar.declarations = declar.declarations.concat(node.declarations);
|
||||
});
|
||||
|
||||
return declar;
|
||||
}
|
||||
|
||||
return nodes;
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "1.10.7",
|
||||
"version": "1.10.9",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/sebmck/6to5",
|
||||
"repository": {
|
||||
|
||||
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