add new compress option unsafe_methods for ecma >= 6 (#2325)

fixes #2321
This commit is contained in:
kzc
2017-09-19 12:15:54 -04:00
committed by Alex Lam S.L
parent c46b9f361a
commit e8235657e4
5 changed files with 50 additions and 1 deletions

View File

@@ -88,6 +88,7 @@ function Compressor(options, false_by_default) {
unsafe_comps : false,
unsafe_Func : false,
unsafe_math : false,
unsafe_methods: false,
unsafe_proto : false,
unsafe_regexp : false,
unused : !false_by_default,
@@ -4866,7 +4867,7 @@ merge(Compressor.prototype, {
// p:async function(){} ---> async p(){}
// p:()=>{} ---> p(){}
// p:async()=>{} ---> async p(){}
if (compressor.option("ecma") >= 6) {
if (compressor.option("unsafe_methods") && compressor.option("ecma") >= 6) {
var key = self.key;
var value = self.value;
var is_arrow_with_block = value instanceof AST_Arrow