fix corner case in pure_getters (#5617)

This commit is contained in:
Alex Lam S.L
2022-08-13 19:54:06 +01:00
committed by GitHub
parent 612701a706
commit dd90135944
2 changed files with 58 additions and 2 deletions

View File

@@ -4469,7 +4469,13 @@ Compressor.prototype.compress = function(node) {
def(AST_Binary, function(compressor) {
return lazy_op[this.operator] && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
});
def(AST_Class, return_false);
def(AST_Class, function(compressor, force) {
return is_strict(compressor, force) && !all(this.properties, function(prop) {
if (prop.private) return true;
if (!prop.static) return true;
return !(prop instanceof AST_ClassGetter || prop instanceof AST_ClassSetter);
});
});
def(AST_Conditional, function(compressor) {
return this.consequent._dot_throw(compressor) || this.alternative._dot_throw(compressor);
});
@@ -4484,7 +4490,7 @@ Compressor.prototype.compress = function(node) {
def(AST_Null, return_true);
def(AST_Object, function(compressor, force) {
return is_strict(compressor, force) && !all(this.properties, function(prop) {
if (!(prop instanceof AST_ObjectKeyVal)) return false;
if (prop instanceof AST_ObjectGetter || prop instanceof AST_ObjectSetter) return false;
return !(prop.key === "__proto__" && prop.value._dot_throw(compressor, force));
});
});