Add drop_error to new Error

Apply option to new Error also
This commit is contained in:
pborunda 2017-02-25 10:34:26 -07:00
parent 43ff5ed37f
commit 6bf36b73ef

View File

@ -2627,6 +2627,23 @@ merge(Compressor.prototype, {
});
OPT(AST_New, function(self, compressor){
if (compressor.option("drop_error")) {
var exp = self.expression;
if (exp instanceof AST_SymbolRef
&& (exp.name == "Error" ||
exp.name == "EvalError" ||
exp.name == "InternalError" ||
exp.name == "RangeError" ||
exp.name == "ReferenceError" ||
exp.name == "SyntaxError" ||
exp.name == "TypeError" ||
exp.name == "URIError")
&& exp.undeclared()) {
// drop error description(s)
self.args = [];
}
}
if (compressor.option("unsafe")) {
var exp = self.expression;
if (exp instanceof AST_SymbolRef && exp.undeclared()) {