@@ -4824,7 +4824,8 @@ merge(Compressor.prototype, {
|
||||
arrow.is_generator = self.is_generator;
|
||||
return make_node(AST_ObjectKeyVal, self, {
|
||||
key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
|
||||
value: arrow
|
||||
value: arrow,
|
||||
quote: self.quote,
|
||||
});
|
||||
}
|
||||
return self;
|
||||
@@ -4850,6 +4851,7 @@ merge(Compressor.prototype, {
|
||||
name: key,
|
||||
}),
|
||||
value: make_node(AST_Accessor, value, value),
|
||||
quote: self.quote,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,9 @@ function mangle_properties(ast, options) {
|
||||
if (node instanceof AST_ObjectKeyVal) {
|
||||
add(node.key, keep_quoted && node.quote);
|
||||
}
|
||||
else if (node instanceof AST_ConciseMethod && node.key && node.key.name) {
|
||||
add(node.key.name, keep_quoted && node.quote);
|
||||
}
|
||||
else if (node instanceof AST_ObjectProperty) {
|
||||
// setter or getter, since KeyVal is handled above
|
||||
add(node.key.name);
|
||||
@@ -139,9 +142,6 @@ function mangle_properties(ast, options) {
|
||||
else if (node instanceof AST_Sub) {
|
||||
addStrings(node.property, keep_quoted);
|
||||
}
|
||||
else if (node instanceof AST_ConciseMethod) {
|
||||
add(node.name.name);
|
||||
}
|
||||
}));
|
||||
|
||||
// step 2: transform the tree, renaming properties
|
||||
@@ -150,6 +150,11 @@ function mangle_properties(ast, options) {
|
||||
if (!(keep_quoted && node.quote))
|
||||
node.key = mangle(node.key);
|
||||
}
|
||||
else if (node instanceof AST_ConciseMethod && node.name && node.key.name) {
|
||||
if (!(keep_quoted && node.quote) && should_mangle(node.key.name)) {
|
||||
node.key.name = mangle(node.key.name);
|
||||
}
|
||||
}
|
||||
else if (node instanceof AST_ObjectProperty) {
|
||||
// setter or getter
|
||||
node.key.name = mangle(node.key.name);
|
||||
@@ -161,11 +166,6 @@ function mangle_properties(ast, options) {
|
||||
if (!keep_quoted)
|
||||
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(
|
||||
|
||||
@@ -870,3 +870,37 @@ issue_2208_9: {
|
||||
expect_stdout: "42"
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
methods_keep_quoted_true: {
|
||||
options = {
|
||||
arrows: true,
|
||||
ecma: 6,
|
||||
}
|
||||
mangle_props = {
|
||||
keep_quoted: true,
|
||||
};
|
||||
input: {
|
||||
class C { "Quoted"(){} Unquoted(){} }
|
||||
f1({ "Quoted"(){}, Unquoted(){}, "Prop": 3 });
|
||||
f2({ "Quoted": function(){} });
|
||||
f3({ "Quoted": ()=>{} });
|
||||
}
|
||||
expect_exact: "class C{Quoted(){}o(){}}f1({Quoted(){},o(){},Prop:3});f2({Quoted(){}});f3({Quoted(){}});"
|
||||
}
|
||||
|
||||
methods_keep_quoted_false: {
|
||||
options = {
|
||||
arrows: true,
|
||||
ecma: 6,
|
||||
}
|
||||
mangle_props = {
|
||||
keep_quoted: false,
|
||||
};
|
||||
input: {
|
||||
class C { "Quoted"(){} Unquoted(){} }
|
||||
f1({ "Quoted"(){}, Unquoted(){}, "Prop": 3 });
|
||||
f2({ "Quoted": function(){} });
|
||||
f3({ "Quoted": ()=>{} });
|
||||
}
|
||||
expect_exact: "class C{o(){}d(){}}f1({o(){},d(){},e:3});f2({o(){}});f3({o(){}});"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user