diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-12-27 14:24:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-27 14:24:54 +0000 |
commit | a19d31dd33abdce5ff162d802705cd97cec10b5f (patch) | |
tree | 7926c49eddd35d8fe0b311283931eca062d2f86a /lib/compress.js | |
parent | 01d6e0f223aec7d36d50b960256bfa0f653b35f5 (diff) | |
download | tracifyjs-a19d31dd33abdce5ff162d802705cd97cec10b5f.tar.gz tracifyjs-a19d31dd33abdce5ff162d802705cd97cec10b5f.zip |
fix corner case in `unsafe` (#3646)
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/compress.js b/lib/compress.js index c00b9f07..e277e9a1 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2872,9 +2872,11 @@ merge(Compressor.prototype, { } function convert_to_predicate(obj) { + var map = Object.create(null); Object.keys(obj).forEach(function(key) { - obj[key] = makePredicate(obj[key]); + map[key] = makePredicate(obj[key]); }); + return map; } AST_Lambda.DEFMETHOD("first_statement", function() { @@ -2897,7 +2899,7 @@ merge(Compressor.prototype, { "toString", "valueOf", ]; - var native_fns = { + var native_fns = convert_to_predicate({ Array: [ "indexOf", "join", @@ -2933,9 +2935,8 @@ merge(Compressor.prototype, { "toUpperCase", "trim", ].concat(object_fns), - }; - convert_to_predicate(native_fns); - var static_fns = { + }); + var static_fns = convert_to_predicate({ Array: [ "isArray", ], @@ -2975,8 +2976,7 @@ merge(Compressor.prototype, { String: [ "fromCharCode", ], - }; - convert_to_predicate(static_fns); + }); // methods to evaluate a constant expression (function(def) { @@ -3199,7 +3199,7 @@ merge(Compressor.prototype, { Object: Object, String: String, }; - var static_values = { + var static_values = convert_to_predicate({ Math: [ "E", "LN10", @@ -3217,8 +3217,7 @@ merge(Compressor.prototype, { "NEGATIVE_INFINITY", "POSITIVE_INFINITY", ], - }; - convert_to_predicate(static_values); + }); var regexp_props = makePredicate("global ignoreCase multiline source"); def(AST_PropAccess, function(compressor, cached, depth) { if (compressor.option("unsafe")) { |