From 6266f5b9247b0e5237c85663fa7fa7737e3cadfe Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Tue, 10 Feb 2015 17:56:31 +1100 Subject: [PATCH] finish minification.removeConsoleCall transformer #740 --- .../transformers/minification/remove-console-calls.js | 8 ++++++-- lib/6to5/types/index.js | 8 ++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/6to5/transformation/transformers/minification/remove-console-calls.js b/lib/6to5/transformation/transformers/minification/remove-console-calls.js index afdb72f233..3c53dd53bc 100644 --- a/lib/6to5/transformation/transformers/minification/remove-console-calls.js +++ b/lib/6to5/transformation/transformers/minification/remove-console-calls.js @@ -6,8 +6,12 @@ var isConsole = t.buildMatchMemberExpression("console", true); exports.optional = true; -exports.CallExpression = function (node) { +exports.CallExpression = function (node, parent) { if (isConsole(node.callee)) { - this.remove(); + if (t.isExpressionStatement(parent)) { + this.parentPath.remove(); + } else { + this.remove(); + } } }; diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index 8e38945803..a2b4445c00 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -444,12 +444,8 @@ t.buildMatchMemberExpression = function (match, allowPartial) { } // too many parts - if (++i > parts.length) { - if (allowPartial) { - return true; - } else { - return false; - } + if (++i >= parts.length) { + return !!allowPartial; } }