@@ -70,7 +70,7 @@ function Compressor(options, false_by_default) {
70
70
hoist_funs : false,
71
71
hoist_props : !false_by_default,
72
72
hoist_vars : false,
73
- ie8 : false,
73
+ ie : false,
74
74
if_return : !false_by_default,
75
75
imports : !false_by_default,
76
76
inline : !false_by_default,
@@ -206,7 +206,7 @@ merge(Compressor.prototype, {
206
206
var passes = +this.options.passes || 1;
207
207
var min_count = 1 / 0;
208
208
var stopping = false;
209
- var mangle = { ie8 : this.option("ie8 ") };
209
+ var mangle = { ie : this.option("ie ") };
210
210
for (var pass = 0; pass < passes; pass++) {
211
211
node.figure_out_scope(mangle);
212
212
if (pass > 0 || this.option("reduce_vars"))
@@ -513,7 +513,7 @@ merge(Compressor.prototype, {
513
513
if (scope.uses_arguments) scope.each_argname(function(node) {
514
514
node.definition().last_ref = false;
515
515
});
516
- if (compressor.option("ie8 ")) scope.variables.each(function(def) {
516
+ if (compressor.option("ie ")) scope.variables.each(function(def) {
517
517
var d = def.orig[0].definition();
518
518
if (d !== def) d.fixed = false;
519
519
});
@@ -2249,7 +2249,7 @@ merge(Compressor.prototype, {
2249
2249
return side_effects || lhs instanceof AST_PropAccess || may_modify(lhs);
2250
2250
}
2251
2251
if (node instanceof AST_Function) {
2252
- return compressor.option("ie8 ") && node.name && lvalues.has(node.name.name);
2252
+ return compressor.option("ie ") && node.name && lvalues.has(node.name.name);
2253
2253
}
2254
2254
if (node instanceof AST_ObjectIdentity) return symbol_in_lvalues(node, parent);
2255
2255
if (node instanceof AST_PropAccess) {
@@ -4208,7 +4208,7 @@ merge(Compressor.prototype, {
4208
4208
4209
4209
AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
4210
4210
if (!compressor.option("global_defs")) return this;
4211
- this.figure_out_scope({ ie8 : compressor.option("ie8 ") });
4211
+ this.figure_out_scope({ ie : compressor.option("ie ") });
4212
4212
return this.transform(new TreeTransformer(function(node) {
4213
4213
var def = node._find_defs(compressor, "");
4214
4214
if (!def) return;
@@ -5672,7 +5672,7 @@ merge(Compressor.prototype, {
5672
5672
if (node instanceof AST_Call) {
5673
5673
var exp = node.expression;
5674
5674
var tail = exp.tail_node();
5675
- if (!(tail instanceof AST_LambdaExpression)) return;
5675
+ if (!(tail instanceof AST_LambdaExpression)) return walk_node_with_expr(node) ;
5676
5676
if (exp !== tail) exp.expressions.slice(0, -1).forEach(function(node) {
5677
5677
node.walk(tw);
5678
5678
});
@@ -5788,6 +5788,7 @@ merge(Compressor.prototype, {
5788
5788
pop();
5789
5789
return true;
5790
5790
}
5791
+ if (node instanceof AST_Sub) return walk_node_with_expr(node);
5791
5792
if (node instanceof AST_Switch) {
5792
5793
node.expression.walk(tw);
5793
5794
var save = segment;
@@ -5886,6 +5887,15 @@ merge(Compressor.prototype, {
5886
5887
pop();
5887
5888
return true;
5888
5889
}
5890
+
5891
+ function walk_node_with_expr(node) {
5892
+ descend();
5893
+ if (compressor.option("ie")) {
5894
+ var sym = root_expr(node.expression);
5895
+ if (sym instanceof AST_SymbolRef) sym.walk(tw);
5896
+ }
5897
+ return true;
5898
+ }
5889
5899
});
5890
5900
tw.directives = Object.create(compressor.directives);
5891
5901
self.walk(tw);
@@ -6235,7 +6245,7 @@ merge(Compressor.prototype, {
6235
6245
});
6236
6246
tw.directives = Object.create(compressor.directives);
6237
6247
self.walk(tw);
6238
- var drop_fn_name = compressor.option("keep_fnames") ? return_false : compressor.option("ie8 ") ? function(def) {
6248
+ var drop_fn_name = compressor.option("keep_fnames") ? return_false : compressor.option("ie ") ? function(def) {
6239
6249
return !compressor.exposed(def) && def.references.length == def.replaced;
6240
6250
} : function(def) {
6241
6251
if (!(def.id in in_use_ids)) return true;
@@ -6247,7 +6257,7 @@ merge(Compressor.prototype, {
6247
6257
return !ref.in_arg;
6248
6258
});
6249
6259
};
6250
- if (compressor.option("ie8 ")) initializations.each(function(init, id) {
6260
+ if (compressor.option("ie ")) initializations.each(function(init, id) {
6251
6261
if (id in in_use_ids) return;
6252
6262
init.forEach(function(init) {
6253
6263
init.walk(new TreeWalker(function(node) {
@@ -6535,7 +6545,7 @@ merge(Compressor.prototype, {
6535
6545
head.push(def);
6536
6546
}
6537
6547
} else if (compressor.option("functions")
6538
- && !compressor.option("ie8 ")
6548
+ && !compressor.option("ie ")
6539
6549
&& drop_sym
6540
6550
&& var_defs[sym.id] == 1
6541
6551
&& sym.assignments == 0
@@ -7652,7 +7662,7 @@ merge(Compressor.prototype, {
7652
7662
});
7653
7663
7654
7664
function fn_name_unused(fn, compressor) {
7655
- if (!fn.name || !compressor.option("ie8 ")) return true;
7665
+ if (!fn.name || !compressor.option("ie ")) return true;
7656
7666
var def = fn.name.definition();
7657
7667
if (compressor.exposed(def)) return false;
7658
7668
return all(def.references, function(sym) {
@@ -7969,7 +7979,7 @@ merge(Compressor.prototype, {
7969
7979
var alternative = this.alternative.drop_side_effect_free(compressor);
7970
7980
if (consequent === this.consequent && alternative === this.alternative) return this;
7971
7981
var exprs;
7972
- if (compressor.option("ie8 ")) {
7982
+ if (compressor.option("ie ")) {
7973
7983
exprs = [];
7974
7984
if (consequent instanceof AST_Function) {
7975
7985
exprs.push(consequent);
@@ -7998,7 +8008,7 @@ merge(Compressor.prototype, {
7998
8008
node.consequent = consequent;
7999
8009
node.alternative = alternative;
8000
8010
}
8001
- if (!compressor.option("ie8 ")) return node;
8011
+ if (!compressor.option("ie ")) return node;
8002
8012
if (node) exprs.push(node);
8003
8013
return exprs.length == 0 ? null : make_sequence(this, exprs);
8004
8014
});
@@ -9411,7 +9421,7 @@ merge(Compressor.prototype, {
9411
9421
return arg.value;
9412
9422
}).join() + "){" + self.args[self.args.length - 1].value + "})";
9413
9423
var ast = parse(code);
9414
- var mangle = { ie8 : compressor.option("ie8 ") };
9424
+ var mangle = { ie : compressor.option("ie ") };
9415
9425
ast.figure_out_scope(mangle);
9416
9426
var comp = new Compressor(compressor.options);
9417
9427
ast = ast.transform(comp);
@@ -10465,7 +10475,7 @@ merge(Compressor.prototype, {
10465
10475
&& self.right.operator == "typeof") {
10466
10476
var expr = self.right.expression;
10467
10477
if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
10468
- : !(expr instanceof AST_PropAccess && compressor.option("ie8 "))) {
10478
+ : !(expr instanceof AST_PropAccess && compressor.option("ie "))) {
10469
10479
self.right = expr;
10470
10480
self.left = make_node(AST_Undefined, self.left).optimize(compressor);
10471
10481
if (self.operator.length == 2) self.operator += "=";
@@ -11079,7 +11089,7 @@ merge(Compressor.prototype, {
11079
11089
}
11080
11090
11081
11091
OPT(AST_SymbolRef, function(self, compressor) {
11082
- if (!compressor.option("ie8 ")
11092
+ if (!compressor.option("ie ")
11083
11093
&& is_undeclared_ref(self)
11084
11094
// testing against `self.scope.uses_with` is an optimization
11085
11095
&& !(self.scope.resolve().uses_with && compressor.find_parent(AST_With))) {
@@ -11121,7 +11131,7 @@ merge(Compressor.prototype, {
11121
11131
single_use = false;
11122
11132
} else if (fixed.has_side_effects(compressor)) {
11123
11133
single_use = false;
11124
- } else if (compressor.option("ie8 ") && fixed instanceof AST_Class) {
11134
+ } else if (compressor.option("ie ") && fixed instanceof AST_Class) {
11125
11135
single_use = false;
11126
11136
}
11127
11137
if (single_use) fixed.parent_scope = self.scope;
0 commit comments