fix corner case in hoist_props (#5069)

This commit is contained in:
Alex Lam S.L
2021-07-11 03:59:57 +01:00
committed by GitHub
parent d147d5d7f0
commit 08391b8e1c
3 changed files with 55 additions and 24 deletions

View File

@@ -1345,16 +1345,10 @@ var AST_PropAccess = DEFNODE("PropAccess", "expression optional property", {
optional: "[boolean] whether the expression is optional chaining",
property: "[AST_Node|string] the property to access. For AST_Dot this is always a plain string, while for AST_Sub it's an arbitrary AST_Node",
},
getProperty: function() {
get_property: function() {
var p = this.property;
if (p instanceof AST_Constant) {
return p.value;
}
if (p instanceof AST_UnaryPrefix
&& p.operator == "void"
&& p.expression instanceof AST_Constant) {
return;
}
if (p instanceof AST_Constant) return p.value;
if (p instanceof AST_UnaryPrefix && p.operator == "void" && p.expression instanceof AST_Constant) return;
return p;
},
_validate: function() {