From c99eaae360c8baab973a7c9d7e14dbbb2ade8529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Santos?= Date: Mon, 26 Oct 2015 22:15:21 +0000 Subject: [PATCH] Make concise methods work with propmangle --- lib/propmangle.js | 8 ++++++++ test/compress/harmony.js | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lib/propmangle.js b/lib/propmangle.js index ff782b57..86da5de9 100644 --- a/lib/propmangle.js +++ b/lib/propmangle.js @@ -107,6 +107,9 @@ function mangle_properties(ast, options) { addStrings(node.property); } } + else if (node instanceof AST_ConciseMethod) { + add(node.name.name); + } })); // step 2: transform the tree, renaming properties @@ -129,6 +132,11 @@ function mangle_properties(ast, options) { else if (node instanceof AST_Sub) { node.property = mangleStrings(node.property); } + else if (node instanceof AST_ConciseMethod) { + if (should_mangle(node.name.name)) { + node.name.name = mangle(node.name.name); + } + } // else if (node instanceof AST_String) { // if (should_mangle(node.value)) { // AST_Node.warn( diff --git a/test/compress/harmony.js b/test/compress/harmony.js index 19628be4..2525d252 100644 --- a/test/compress/harmony.js +++ b/test/compress/harmony.js @@ -149,6 +149,26 @@ concise_methods: { expect_exact: "x={foo(a,b){return x}};y={foo([{a}]){return a},bar(){}};" } +concise_methods_and_mangle_props: { + mangle_props = { + regex: /_/ + }; + input: { + function x() { + obj = { + _foo() { return 1; } + } + } + } + expect: { + function x() { + obj = { + a() { return 1; } + } + } + } +} + number_literals: { input: { 0b1001;