fix corner case in unsafe (#3646)
This commit is contained in:
@@ -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")) {
|
||||
|
||||
Reference in New Issue
Block a user