Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da8edecc09 | ||
|
|
cd6dea6480 | ||
|
|
69d7ac0e0c | ||
|
|
dae46bfbfa |
@@ -1,3 +1,7 @@
|
||||
# 1.14.12
|
||||
|
||||
* Fix duplicate dynamic expressions in call spread.
|
||||
|
||||
# 1.14.10
|
||||
|
||||
* Fix let scoping unneccesary override.
|
||||
|
||||
@@ -56,7 +56,7 @@ exports.ArrayExpression = function (node, parent, file) {
|
||||
return t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes);
|
||||
};
|
||||
|
||||
exports.CallExpression = function (node, parent, file) {
|
||||
exports.CallExpression = function (node, parent, file, scope) {
|
||||
var args = node.arguments;
|
||||
if (!hasSpread(args)) return;
|
||||
|
||||
@@ -79,10 +79,16 @@ exports.CallExpression = function (node, parent, file) {
|
||||
}
|
||||
|
||||
var callee = node.callee;
|
||||
var temp;
|
||||
|
||||
if (t.isMemberExpression(callee)) {
|
||||
contextLiteral = callee.object;
|
||||
|
||||
if (t.isDynamic(contextLiteral)) {
|
||||
temp = contextLiteral = scope.generateTemp(file);
|
||||
callee.object = t.assignmentExpression("=", temp, callee.object);
|
||||
}
|
||||
|
||||
if (callee.computed) {
|
||||
callee.object = t.memberExpression(callee.object, callee.property, true);
|
||||
callee.property = t.identifier("apply");
|
||||
|
||||
@@ -30,12 +30,7 @@ exports.AssignmentExpression = function (node, parent, file, scope) {
|
||||
if (!t.isExpressionStatement(parent)) {
|
||||
// `node.right` isn't a simple identifier so we need to reference it
|
||||
if (t.isDynamic(value)) {
|
||||
var tempName = file.generateUid("temp");
|
||||
temp = value = t.identifier(tempName);
|
||||
scope.push({
|
||||
key: tempName,
|
||||
id: temp
|
||||
});
|
||||
temp = value = scope.generateTemp(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,12 +70,7 @@ exports.CallExpression = function (node, parent, file, scope) {
|
||||
var temp;
|
||||
if (t.isDynamic(callee.object)) {
|
||||
// we need to save `callee.object` so we can call it again
|
||||
var tempName = file.generateUid("temp");
|
||||
temp = t.identifier(tempName);
|
||||
scope.push({
|
||||
key: tempName,
|
||||
id: temp
|
||||
});
|
||||
temp = scope.generateTemp(file);
|
||||
}
|
||||
|
||||
var call = util.template("abstract-expression-call", {
|
||||
|
||||
@@ -7,12 +7,7 @@ exports.BindMemberExpression = function (node, parent, file, scope) {
|
||||
|
||||
var temp;
|
||||
if (t.isDynamic(object)) {
|
||||
var tempName = file.generateUid("temp", scope);
|
||||
temp = object = t.identifier(tempName);
|
||||
scope.push({
|
||||
key: tempName,
|
||||
id: temp
|
||||
});
|
||||
temp = object = scope.generateTemp(file);
|
||||
}
|
||||
|
||||
var call = t.callExpression(
|
||||
@@ -39,17 +34,12 @@ exports.BindFunctionExpression = function (node, parent, file, scope) {
|
||||
};
|
||||
|
||||
if (_.find(node.arguments, t.isDynamic)) {
|
||||
var argsIdName = file.generateUid("args", scope);
|
||||
var argsId = t.identifier(argsIdName);
|
||||
scope.push({
|
||||
key: argsIdName,
|
||||
id: argsId
|
||||
});
|
||||
var temp = scope.generateTemp(file, "args");
|
||||
|
||||
return t.sequenceExpression([
|
||||
t.assignmentExpression("=", argsId, t.arrayExpression(node.arguments)),
|
||||
t.assignmentExpression("=", temp, t.arrayExpression(node.arguments)),
|
||||
buildCall(node.arguments.map(function (node, i) {
|
||||
return t.memberExpression(argsId, t.literal(i), true);
|
||||
return t.memberExpression(temp, t.literal(i), true);
|
||||
}))
|
||||
]);
|
||||
} else {
|
||||
|
||||
@@ -26,6 +26,15 @@ Scope.add = function (node, references) {
|
||||
_.defaults(references, t.getIds(node, true));
|
||||
};
|
||||
|
||||
Scope.prototype.generateTemp = function (file, name) {
|
||||
var id = file.generateUidIdentifier(name || "temp", this);
|
||||
this.push({
|
||||
key: id.name,
|
||||
id: id
|
||||
});
|
||||
return id;
|
||||
};
|
||||
|
||||
Scope.prototype.getReferences = function () {
|
||||
var block = this.block;
|
||||
if (block._scopeReferences) return block._scopeReferences;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/6to5/6to5",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user