fix corner case in unsafe (#3380)

This commit is contained in:
Alex Lam S.L
2019-04-24 22:21:28 +08:00
committed by GitHub
parent 6fe20dbe33
commit d3b93ec682
3 changed files with 38 additions and 0 deletions

View File

@@ -3018,6 +3018,7 @@ merge(Compressor.prototype, {
if (arg === value) return this;
args.push(value);
}
if (key == "replace" && typeof args[1] == "function") return this;
try {
return val[key].apply(val, args);
} catch (ex) {
@@ -3139,6 +3140,7 @@ merge(Compressor.prototype, {
} else if (expr instanceof AST_RegExp) {
map = native_fns.RegExp;
} else if (expr.is_string(compressor)) {
if (this.property == "replace") return false;
map = native_fns.String;
} else if (!this.may_throw_on_access(compressor)) {
map = native_fns.Object;