allow RegExp for unsafe_methods compress option (#2327)

This commit is contained in:
kzc
2017-09-20 12:48:16 -04:00
committed by Alex Lam S.L
parent e8235657e4
commit a784717fe2
3 changed files with 59 additions and 1 deletions

View File

@@ -4867,7 +4867,10 @@ merge(Compressor.prototype, {
// p:async function(){} ---> async p(){}
// p:()=>{} ---> p(){}
// p:async()=>{} ---> async p(){}
if (compressor.option("unsafe_methods") && compressor.option("ecma") >= 6) {
var unsafe_methods = compressor.option("unsafe_methods");
if (unsafe_methods
&& compressor.option("ecma") >= 6
&& (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
var key = self.key;
var value = self.value;
var is_arrow_with_block = value instanceof AST_Arrow