fix-ups for #2258
This commit is contained in:
@@ -93,6 +93,8 @@ function reserve_quoted_keys(ast, reserved) {
|
|||||||
ast.walk(new TreeWalker(function(node) {
|
ast.walk(new TreeWalker(function(node) {
|
||||||
if (node instanceof AST_ObjectKeyVal && node.quote) {
|
if (node instanceof AST_ObjectKeyVal && node.quote) {
|
||||||
add(node.key);
|
add(node.key);
|
||||||
|
} else if (node instanceof AST_ObjectProperty && node.quote) {
|
||||||
|
add(node.key.name);
|
||||||
} else if (node instanceof AST_Sub) {
|
} else if (node instanceof AST_Sub) {
|
||||||
addStrings(node.property, add);
|
addStrings(node.property, add);
|
||||||
}
|
}
|
||||||
@@ -155,9 +157,6 @@ function mangle_properties(ast, options) {
|
|||||||
if (node instanceof AST_ObjectKeyVal) {
|
if (node instanceof AST_ObjectKeyVal) {
|
||||||
add(node.key);
|
add(node.key);
|
||||||
}
|
}
|
||||||
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) {
|
else if (node instanceof AST_ObjectProperty) {
|
||||||
// setter or getter, since KeyVal is handled above
|
// setter or getter, since KeyVal is handled above
|
||||||
add(node.key.name);
|
add(node.key.name);
|
||||||
@@ -175,11 +174,6 @@ function mangle_properties(ast, options) {
|
|||||||
if (node instanceof AST_ObjectKeyVal) {
|
if (node instanceof AST_ObjectKeyVal) {
|
||||||
node.key = mangle(node.key);
|
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) {
|
else if (node instanceof AST_ObjectProperty) {
|
||||||
// setter or getter
|
// setter or getter
|
||||||
node.key.name = mangle(node.key.name);
|
node.key.name = mangle(node.key.name);
|
||||||
|
|||||||
@@ -284,9 +284,11 @@ concise_methods_with_various_property_names: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
concise_methods_and_mangle_props: {
|
concise_methods_and_mangle_props: {
|
||||||
mangle_props = {
|
mangle = {
|
||||||
regex: /_/
|
properties: {
|
||||||
};
|
regex: /_/,
|
||||||
|
},
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function x() {
|
function x() {
|
||||||
obj = {
|
obj = {
|
||||||
|
|||||||
@@ -888,9 +888,11 @@ methods_keep_quoted_true: {
|
|||||||
arrows: true,
|
arrows: true,
|
||||||
ecma: 6,
|
ecma: 6,
|
||||||
}
|
}
|
||||||
mangle_props = {
|
mangle = {
|
||||||
keep_quoted: true,
|
properties: {
|
||||||
};
|
keep_quoted: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
class C { "Quoted"(){} Unquoted(){} }
|
class C { "Quoted"(){} Unquoted(){} }
|
||||||
f1({ "Quoted"(){}, Unquoted(){}, "Prop": 3 });
|
f1({ "Quoted"(){}, Unquoted(){}, "Prop": 3 });
|
||||||
@@ -905,9 +907,11 @@ methods_keep_quoted_false: {
|
|||||||
arrows: true,
|
arrows: true,
|
||||||
ecma: 6,
|
ecma: 6,
|
||||||
}
|
}
|
||||||
mangle_props = {
|
mangle = {
|
||||||
keep_quoted: false,
|
properties: {
|
||||||
};
|
keep_quoted: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
class C { "Quoted"(){} Unquoted(){} }
|
class C { "Quoted"(){} Unquoted(){} }
|
||||||
f1({ "Quoted"(){}, Unquoted(){}, "Prop": 3 });
|
f1({ "Quoted"(){}, Unquoted(){}, "Prop": 3 });
|
||||||
@@ -917,6 +921,32 @@ methods_keep_quoted_false: {
|
|||||||
expect_exact: "class C{o(){}d(){}}f1({o(){},d(){},e:3});f2({o(){}});f3({o(){}});"
|
expect_exact: "class C{o(){}d(){}}f1({o(){},d(){},e:3});f2({o(){}});f3({o(){}});"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
methods_keep_quoted_from_dead_code: {
|
||||||
|
options = {
|
||||||
|
arrows: true,
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
ecma: 6,
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
mangle = {
|
||||||
|
properties: {
|
||||||
|
keep_quoted: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
class C { Quoted(){} Unquoted(){} }
|
||||||
|
f1({ Quoted(){}, Unquoted(){}, "Prop": 3 });
|
||||||
|
f2({ Quoted: function(){} });
|
||||||
|
f3({ Quoted: ()=>{} });
|
||||||
|
0 && obj["Quoted"];
|
||||||
|
}
|
||||||
|
expect_exact: "class C{Quoted(){}o(){}}f1({Quoted(){},o(){},Prop:3});f2({Quoted(){}});f3({Quoted(){}});"
|
||||||
|
}
|
||||||
|
|
||||||
issue_2256: {
|
issue_2256: {
|
||||||
options = {
|
options = {
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user