Make concise methods work with propmangle

This commit is contained in:
Fábio Santos
2015-10-26 22:15:21 +00:00
committed by Richard van Velzen
parent 34213ea2f8
commit c99eaae360
2 changed files with 28 additions and 0 deletions

View File

@@ -107,6 +107,9 @@ function mangle_properties(ast, options) {
addStrings(node.property); addStrings(node.property);
} }
} }
else if (node instanceof AST_ConciseMethod) {
add(node.name.name);
}
})); }));
// step 2: transform the tree, renaming properties // step 2: transform the tree, renaming properties
@@ -129,6 +132,11 @@ function mangle_properties(ast, options) {
else if (node instanceof AST_Sub) { else if (node instanceof AST_Sub) {
node.property = mangleStrings(node.property); 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) { // else if (node instanceof AST_String) {
// if (should_mangle(node.value)) { // if (should_mangle(node.value)) {
// AST_Node.warn( // AST_Node.warn(

View File

@@ -149,6 +149,26 @@ concise_methods: {
expect_exact: "x={foo(a,b){return x}};y={foo([{a}]){return a},bar(){}};" 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: { number_literals: {
input: { input: {
0b1001; 0b1001;