aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-04-07 13:31:58 +0800
committerGitHub <noreply@github.com>2017-04-07 13:31:58 +0800
commit0f4cd73dcc5d8a936ae3630a7992dbcb44274136 (patch)
tree3c5724a3ef73c80868849800630c92d57d28b806 /lib/compress.js
parent281e882d27ace48c5c415f19292e2590dd4473dc (diff)
downloadtracifyjs-0f4cd73dcc5d8a936ae3630a7992dbcb44274136.tar.gz
tracifyjs-0f4cd73dcc5d8a936ae3630a7992dbcb44274136.zip
introduce "strict" to `pure_getters` (#1795)
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 8df6e58f..c199d13f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -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);
});