fix corner case in spread (#4370)

This commit is contained in:
Alex Lam S.L
2020-12-11 22:45:59 +00:00
committed by GitHub
parent 2123f38394
commit fd0d28e465
2 changed files with 31 additions and 7 deletions

View File

@@ -10051,13 +10051,14 @@ merge(Compressor.prototype, {
found = true;
var exp = prop.expression;
if (compressor.option("spread") && exp instanceof AST_Object && all(exp.properties, function(prop) {
return !(prop instanceof AST_ObjectGetter
|| prop instanceof AST_ObjectSetter && prop.key instanceof AST_Node
|| prop instanceof AST_Spread);
return !(prop instanceof AST_ObjectGetter || prop instanceof AST_Spread);
})) {
changed = true;
exp.properties.forEach(function(prop) {
if (prop instanceof AST_ObjectKeyVal) process(prop);
process(prop instanceof AST_ObjectSetter ? make_node(AST_ObjectKeyVal, prop, {
key: prop.key,
value: make_node(AST_Undefined, prop).optimize(compressor)
}) : prop);
});
} else {
generated = true;