fix corner cases in parse & unused (#5000)

This commit is contained in:
Alex Lam S.L
2021-06-12 17:10:01 +01:00
committed by GitHub
parent 70ceda5398
commit f8b2215145
5 changed files with 42 additions and 43 deletions

View File

@@ -1510,7 +1510,7 @@ merge(Compressor.prototype, {
function is_lhs_read_only(lhs, compressor) {
if (lhs instanceof AST_ObjectIdentity) return true;
if (lhs instanceof AST_PropAccess) {
if (lhs.property == "__proto__") return true;
if (lhs.property === "__proto__") return true;
lhs = lhs.expression;
if (lhs instanceof AST_SymbolRef) {
if (lhs.is_immutable()) return false;
@@ -3842,7 +3842,7 @@ merge(Compressor.prototype, {
def(AST_Object, function(compressor, force) {
return is_strict(compressor, force) && !all(this.properties, function(prop) {
if (!(prop instanceof AST_ObjectKeyVal)) return false;
return !(prop.key == "__proto__" && prop.value._dot_throw(compressor, force));
return !(prop.key === "__proto__" && prop.value._dot_throw(compressor, force));
});
});
def(AST_ObjectIdentity, function(compressor, force) {
@@ -6727,7 +6727,7 @@ merge(Compressor.prototype, {
return insert_statements(body, node, in_list);
}
if (node instanceof AST_Import) {
if (node.properties && node.properties == 0) node.properties = null;
if (node.properties && node.properties.length == 0) node.properties = null;
return node;
}
if (node instanceof AST_Sequence) {
@@ -11809,7 +11809,7 @@ merge(Compressor.prototype, {
var props = expr.properties;
for (var i = props.length; --i >= 0;) {
var prop = props[i];
if (prop.key != key) continue;
if (prop.key !== key) continue;
if (!all(props, can_hoist_property)) break;
if (!safe_to_flatten(prop.value, compressor)) break;
props = props.map(function(prop) {