introduce "strict" to pure_getters (#1795)
This commit is contained in:
@@ -71,7 +71,7 @@ function Compressor(options, false_by_default) {
|
||||
negate_iife : !false_by_default,
|
||||
passes : 1,
|
||||
properties : !false_by_default,
|
||||
pure_getters : false,
|
||||
pure_getters : !false_by_default && "strict",
|
||||
pure_funcs : null,
|
||||
reduce_vars : !false_by_default,
|
||||
screw_ie8 : true,
|
||||
@@ -1165,7 +1165,13 @@ merge(Compressor.prototype, {
|
||||
// may_eq_null()
|
||||
// returns true if this node may evaluate to null or undefined
|
||||
(function(def) {
|
||||
def(AST_Node, return_true);
|
||||
function is_strict(compressor) {
|
||||
return /strict/.test(compressor.option("pure_getters"));
|
||||
}
|
||||
|
||||
def(AST_Node, function(compressor) {
|
||||
return !is_strict(compressor);
|
||||
});
|
||||
def(AST_Null, return_true);
|
||||
def(AST_Undefined, return_true);
|
||||
def(AST_Constant, return_false);
|
||||
@@ -1198,12 +1204,9 @@ merge(Compressor.prototype, {
|
||||
def(AST_Seq, function(compressor) {
|
||||
return this.cdr.may_eq_null(compressor);
|
||||
});
|
||||
def(AST_PropAccess, function(compressor) {
|
||||
return !compressor.option("unsafe");
|
||||
});
|
||||
def(AST_SymbolRef, function(compressor) {
|
||||
if (this.is_undefined) return true;
|
||||
if (compressor.option("unsafe")) return false;
|
||||
if (!is_strict(compressor)) return false;
|
||||
var fixed = this.fixed_value();
|
||||
return !fixed || fixed.may_eq_null(compressor);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user