From 0c1e1e757cd7703d53adaf2587eac80eabcbd9bc Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 11 Feb 2015 00:02:51 +1100 Subject: [PATCH] default optional builder keys to `false` --- .../transformation/transformers/es6/tail-call.js | 7 +++---- lib/6to5/types/index.js | 12 +++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/6to5/transformation/transformers/es6/tail-call.js b/lib/6to5/transformation/transformers/es6/tail-call.js index fb0325d7aa..3fa4de1efa 100644 --- a/lib/6to5/transformation/transformers/es6/tail-call.js +++ b/lib/6to5/transformation/transformers/es6/tail-call.js @@ -197,11 +197,10 @@ TailCallTransformer.prototype.subTransformSequenceExpression = function (node) { }; TailCallTransformer.prototype.subTransformCallExpression = function (node) { - var callee = node.callee, prop, thisBinding, args; + var callee = node.callee, thisBinding, args; - if (t.isMemberExpression(callee, { computed: false }) && - t.isIdentifier(prop = callee.property)) { - switch (prop.name) { + if (t.isMemberExpression(callee, { computed: false }) && t.isIdentifier(callee.property)) { + switch (callee.property.name) { case "call": args = t.arrayExpression(node.arguments.slice(1)); break; diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index 012bb267e6..0b90c56175 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -105,9 +105,15 @@ each(t.BUILDER_KEYS, function (keys, type) { var node = new Node; node.start = null; node.type = type; - each(keys, function (key, i) { - node[key] = args[i]; - }); + + for (var i = 0; i < keys.length; i++) { + var arg = args[i]; + if (arg === undefined) arg = false; + + var key = keys[i]; + node[key] = arg; + } + return node; }; });