fix up aliasFunctions transformer
This commit is contained in:
@@ -14,7 +14,7 @@ var go = function (getBody, node, file, scope) {
|
||||
};
|
||||
|
||||
// traverse the function and find all alias functions so we can alias
|
||||
// arguments and this if necessary
|
||||
// `arguments` and `this` if necessary
|
||||
traverse(node, function (node) {
|
||||
if (!node._aliasFunction) {
|
||||
if (t.isFunction(node)) {
|
||||
@@ -25,9 +25,9 @@ var go = function (getBody, node, file, scope) {
|
||||
}
|
||||
}
|
||||
|
||||
// traverse all child nodes of this function and find arguments and this
|
||||
// traverse all child nodes of this function and find `arguments` and `this`
|
||||
traverse(node, function (node, parent) {
|
||||
if (t.isFunction(node) && node._aliasFunction !== "arrows") {
|
||||
if (t.isFunction(node) && !node._aliasFunction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
var singleArrayExpression = function (node) {
|
||||
var block = node.blocks[0];
|
||||
@@ -13,7 +14,13 @@ var singleArrayExpression = function (node) {
|
||||
ARRAY: block.right,
|
||||
KEY: block.left
|
||||
});
|
||||
result._aliasFunction = true;
|
||||
|
||||
_.each([result.callee.object, result], function (call) {
|
||||
if (t.isCallExpression(call)) {
|
||||
call.arguments[0]._aliasFunction = true;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -23,7 +30,7 @@ var multiple = function (node, file) {
|
||||
var container = util.template("array-comprehension-container", {
|
||||
KEY: uid
|
||||
});
|
||||
container._aliasFunction = true;
|
||||
container.callee.expression._aliasFunction = true;
|
||||
|
||||
var block = container.callee.expression.body;
|
||||
var body = block.body;
|
||||
|
||||
@@ -3,7 +3,7 @@ var t = require("../../types");
|
||||
exports.ArrowFunctionExpression = function (node) {
|
||||
t.ensureBlock(node);
|
||||
|
||||
node._aliasFunction = "arrows";
|
||||
node._aliasFunction = true;
|
||||
node.expression = false;
|
||||
node.type = "FunctionExpression";
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ exports.ObjectExpression = function (node, parent, file) {
|
||||
var containerCallee = container.callee.expression;
|
||||
var containerBody = containerCallee.body.body;
|
||||
|
||||
containerCallee._aliasFunction = "arrows";
|
||||
containerCallee._aliasFunction = true;
|
||||
|
||||
_.each(computed, function (prop) {
|
||||
containerBody.unshift(
|
||||
|
||||
Reference in New Issue
Block a user