From 0795693d97bba847e63c0b6a473f1a62518c3865 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 13 Oct 2014 12:45:52 +1100 Subject: [PATCH] nice alias function definitions --- lib/6to5/transformers/_alias-functions.js | 5 +++-- lib/6to5/transformers/arrow-functions.js | 3 +-- lib/6to5/transformers/computed-property-names.js | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/6to5/transformers/_alias-functions.js b/lib/6to5/transformers/_alias-functions.js index 4f9d5251e2..234b312cf7 100644 --- a/lib/6to5/transformers/_alias-functions.js +++ b/lib/6to5/transformers/_alias-functions.js @@ -17,7 +17,8 @@ var go = function (getBody, node, file) { // traverse the function and find all alias functions so we can alias // arguments and this if neccesary traverse(node, function (node) { - if (!node._aliasFunction) { + var _aliasFunction = node._aliasFunction; + if (!_aliasFunction) { if (traverse.isFunction(node)) { // stop traversal of this node as it'll be hit again by this transformer return false; @@ -39,7 +40,7 @@ var go = function (getBody, node, file) { } if (util.isReferenced(node, parent)) return getId(); - }, node._aliasFunctionStopNonArrowFunctions && ["FunctionExpression", "FunctionDeclaration"]); + }, _aliasFunction === "arrows" && ["FunctionExpression", "FunctionDeclaration"]); return false; }); diff --git a/lib/6to5/transformers/arrow-functions.js b/lib/6to5/transformers/arrow-functions.js index 34c1e07200..feebb5213e 100644 --- a/lib/6to5/transformers/arrow-functions.js +++ b/lib/6to5/transformers/arrow-functions.js @@ -3,8 +3,7 @@ var util = require("../util"); exports.ArrowFunctionExpression = function (node) { util.ensureBlock(node); - node._aliasFunction = true; - node._aliasFunctionStopNonArrowFunctions = true; + node._aliasFunction = "arrows"; node.expression = false; node.type = "FunctionExpression"; diff --git a/lib/6to5/transformers/computed-property-names.js b/lib/6to5/transformers/computed-property-names.js index bba4e6da94..8aab971290 100644 --- a/lib/6to5/transformers/computed-property-names.js +++ b/lib/6to5/transformers/computed-property-names.js @@ -44,8 +44,7 @@ exports.ObjectExpression = function (node, parent, file) { var containerCallee = container.callee; var containerBody = containerCallee.body.body; - containerCallee._aliasFunction = true; - containerCallee._aliasFunctionStopNonArrowFunctions = true; + containerCallee._aliasFunction = "arrows"; _.each(computed, function (prop) { containerBody.unshift(util.template("obj-key-set", {