Merge branch 'master' into harmony-v2.8.5
This commit is contained in:
@@ -182,6 +182,13 @@ merge(Compressor.prototype, {
|
|||||||
var reduce_vars = rescan && compressor.option("reduce_vars");
|
var reduce_vars = rescan && compressor.option("reduce_vars");
|
||||||
var safe_ids = [];
|
var safe_ids = [];
|
||||||
push();
|
push();
|
||||||
|
var suppressor = new TreeWalker(function(node) {
|
||||||
|
if (node instanceof AST_Symbol) {
|
||||||
|
var d = node.definition();
|
||||||
|
if (node instanceof AST_SymbolRef) d.references.push(node);
|
||||||
|
d.fixed = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
var tw = new TreeWalker(function(node){
|
var tw = new TreeWalker(function(node){
|
||||||
if (!(node instanceof AST_Directive || node instanceof AST_Constant)) {
|
if (!(node instanceof AST_Directive || node instanceof AST_Constant)) {
|
||||||
node._squeezed = false;
|
node._squeezed = false;
|
||||||
@@ -244,9 +251,7 @@ merge(Compressor.prototype, {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_ForIn) {
|
if (node instanceof AST_ForIn) {
|
||||||
if (node.init instanceof AST_SymbolRef) {
|
node.init.walk(suppressor);
|
||||||
node.init.definition().fixed = false;
|
|
||||||
}
|
|
||||||
node.object.walk(tw);
|
node.object.walk(tw);
|
||||||
push();
|
push();
|
||||||
node.body.walk(tw);
|
node.body.walk(tw);
|
||||||
@@ -485,8 +490,12 @@ merge(Compressor.prototype, {
|
|||||||
// Constant single use vars can be replaced in any scope.
|
// Constant single use vars can be replaced in any scope.
|
||||||
if (var_decl.value.is_constant()) {
|
if (var_decl.value.is_constant()) {
|
||||||
var ctt = new TreeTransformer(function(node) {
|
var ctt = new TreeTransformer(function(node) {
|
||||||
if (node === ref)
|
if (node === ref) {
|
||||||
return replace_var(node, ctt.parent(), true);
|
var parent = ctt.parent();
|
||||||
|
if (!(parent instanceof AST_ForIn && parent.init === node)) {
|
||||||
|
return replace_var(node, parent, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
stat.transform(ctt);
|
stat.transform(ctt);
|
||||||
continue;
|
continue;
|
||||||
@@ -575,7 +584,7 @@ merge(Compressor.prototype, {
|
|||||||
// Further optimize statement after substitution.
|
// Further optimize statement after substitution.
|
||||||
stat.reset_opt_flags(compressor);
|
stat.reset_opt_flags(compressor);
|
||||||
|
|
||||||
compressor.warn("Replacing " + (is_constant ? "constant" : "variable") +
|
compressor.warn("Collapsing " + (is_constant ? "constant" : "variable") +
|
||||||
" " + var_name + " [{file}:{line},{col}]", node.start);
|
" " + var_name + " [{file}:{line},{col}]", node.start);
|
||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
return value;
|
return value;
|
||||||
@@ -1074,12 +1083,6 @@ merge(Compressor.prototype, {
|
|||||||
def(AST_Conditional, function(compressor){
|
def(AST_Conditional, function(compressor){
|
||||||
return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
|
return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
|
||||||
});
|
});
|
||||||
def(AST_Call, function(compressor){
|
|
||||||
return compressor.option("unsafe")
|
|
||||||
&& this.expression instanceof AST_SymbolRef
|
|
||||||
&& this.expression.name == "String"
|
|
||||||
&& this.expression.undeclared();
|
|
||||||
});
|
|
||||||
})(function(node, func){
|
})(function(node, func){
|
||||||
node.DEFMETHOD("is_string", func);
|
node.DEFMETHOD("is_string", func);
|
||||||
});
|
});
|
||||||
@@ -1899,16 +1902,18 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
if (assign_as_unused
|
if (assign_as_unused) {
|
||||||
&& node instanceof AST_Assign
|
var n = node;
|
||||||
&& node.operator == "="
|
while (n instanceof AST_Assign
|
||||||
&& node.left instanceof AST_SymbolRef) {
|
&& n.operator == "="
|
||||||
var def = node.left.definition();
|
&& n.left instanceof AST_SymbolRef) {
|
||||||
if ((drop_vars || !def.global)
|
var def = n.left.definition();
|
||||||
&& !(def.id in in_use_ids)
|
if (def.id in in_use_ids
|
||||||
&& self.variables.get(def.name) === def) {
|
|| !drop_vars && def.global
|
||||||
return node.right;
|
|| self.variables.get(def.name) !== def) break;
|
||||||
|
n = n.right;
|
||||||
}
|
}
|
||||||
|
if (n !== node) return n;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_For) {
|
if (node instanceof AST_For) {
|
||||||
descend(node, this);
|
descend(node, this);
|
||||||
@@ -2251,7 +2256,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// self instanceof AST_Do
|
// self instanceof AST_Do
|
||||||
return self.body;
|
return self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (self instanceof AST_While) {
|
if (self instanceof AST_While) {
|
||||||
@@ -2614,6 +2619,20 @@ merge(Compressor.prototype, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
OPT(AST_Call, function(self, compressor){
|
OPT(AST_Call, function(self, compressor){
|
||||||
|
if (compressor.option("unused")
|
||||||
|
&& self.expression instanceof AST_Function
|
||||||
|
&& !self.expression.uses_arguments
|
||||||
|
&& !self.expression.uses_eval
|
||||||
|
&& self.args.length > self.expression.argnames.length) {
|
||||||
|
var end = self.expression.argnames.length;
|
||||||
|
for (var i = end, len = self.args.length; i < len; i++) {
|
||||||
|
var node = self.args[i].drop_side_effect_free(compressor);
|
||||||
|
if (node) {
|
||||||
|
self.args[end++] = node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.args.length = end;
|
||||||
|
}
|
||||||
if (compressor.option("unsafe")) {
|
if (compressor.option("unsafe")) {
|
||||||
var exp = self.expression;
|
var exp = self.expression;
|
||||||
if (exp instanceof AST_SymbolRef && exp.undeclared()) {
|
if (exp instanceof AST_SymbolRef && exp.undeclared()) {
|
||||||
@@ -2815,6 +2834,12 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (self.args.length == 0
|
||||||
|
&& self.expression instanceof AST_Function
|
||||||
|
&& self.expression.body[0] instanceof AST_Return
|
||||||
|
&& self.expression.body[0].value.is_constant()) {
|
||||||
|
return self.expression.body[0].value;
|
||||||
|
}
|
||||||
if (compressor.option("negate_iife")
|
if (compressor.option("negate_iife")
|
||||||
&& compressor.parent() instanceof AST_SimpleStatement
|
&& compressor.parent() instanceof AST_SimpleStatement
|
||||||
&& is_iife_call(self)) {
|
&& is_iife_call(self)) {
|
||||||
@@ -3118,10 +3143,25 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (self.operator == "+" && self.right instanceof AST_String
|
if (self.operator == "+") {
|
||||||
&& self.right.getValue() === "" && self.left instanceof AST_Binary
|
if (self.right instanceof AST_String
|
||||||
&& self.left.operator == "+" && self.left.is_string(compressor)) {
|
&& self.right.getValue() == ""
|
||||||
return self.left;
|
&& self.left.is_string(compressor)) {
|
||||||
|
return self.left;
|
||||||
|
}
|
||||||
|
if (self.left instanceof AST_String
|
||||||
|
&& self.left.getValue() == ""
|
||||||
|
&& self.right.is_string(compressor)) {
|
||||||
|
return self.right;
|
||||||
|
}
|
||||||
|
if (self.left instanceof AST_Binary
|
||||||
|
&& self.left.operator == "+"
|
||||||
|
&& self.left.left instanceof AST_String
|
||||||
|
&& self.left.left.getValue() == ""
|
||||||
|
&& self.right.is_string(compressor)) {
|
||||||
|
self.left = self.left.right;
|
||||||
|
return self.transform(compressor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (compressor.option("evaluate")) {
|
if (compressor.option("evaluate")) {
|
||||||
switch (self.operator) {
|
switch (self.operator) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"homepage": "http://lisperator.net/uglifyjs",
|
"homepage": "http://lisperator.net/uglifyjs",
|
||||||
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"version": "2.8.4",
|
"version": "2.8.5",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1141,7 +1141,7 @@ collapse_vars_constants: {
|
|||||||
function f3(x) {
|
function f3(x) {
|
||||||
var b = x.prop;
|
var b = x.prop;
|
||||||
sideeffect1();
|
sideeffect1();
|
||||||
return b + (function() { return -9; })();
|
return b + -9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1315,3 +1315,31 @@ collapse_vars_regexp: {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_1537: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var k = '';
|
||||||
|
for (k in {prop: 'val'}){}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var k = '';
|
||||||
|
for (k in {prop: 'val'});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_1537_for_of: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var k = '';
|
||||||
|
for (k of {prop: 'val'}){}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var k = '';
|
||||||
|
for (k of {prop: 'val'});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -164,3 +164,53 @@ concat_6: {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
concat_7: {
|
||||||
|
input: {
|
||||||
|
console.log(
|
||||||
|
"" + 1,
|
||||||
|
"" + "1",
|
||||||
|
"" + 1 + 2,
|
||||||
|
"" + 1 + "2",
|
||||||
|
"" + "1" + 2,
|
||||||
|
"" + "1" + "2",
|
||||||
|
"" + (x += "foo")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(
|
||||||
|
"" + 1,
|
||||||
|
"1",
|
||||||
|
"" + 1 + 2,
|
||||||
|
1 + "2",
|
||||||
|
"1" + 2,
|
||||||
|
"1" + "2",
|
||||||
|
x += "foo"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
concat_8: {
|
||||||
|
input: {
|
||||||
|
console.log(
|
||||||
|
1 + "",
|
||||||
|
"1" + "",
|
||||||
|
1 + 2 + "",
|
||||||
|
1 + "2" + "",
|
||||||
|
"1" + 2 + "",
|
||||||
|
"1" + "2" + "",
|
||||||
|
(x += "foo") + ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(
|
||||||
|
1 + "",
|
||||||
|
"1",
|
||||||
|
1 + 2 + "",
|
||||||
|
1 + "2",
|
||||||
|
"1" + 2,
|
||||||
|
"1" + "2",
|
||||||
|
x += "foo"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -760,3 +760,24 @@ const_assign: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_1539: {
|
||||||
|
options = {
|
||||||
|
cascade: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
var a, b;
|
||||||
|
a = b = 42;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
return 42;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -740,6 +740,29 @@ call_args: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
call_args_drop_param: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
keep_fargs: false,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
const a = 1;
|
||||||
|
console.log(a);
|
||||||
|
+function(a) {
|
||||||
|
return a;
|
||||||
|
}(a, b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
const a = 1;
|
||||||
|
console.log(1);
|
||||||
|
+function() {
|
||||||
|
return 1;
|
||||||
|
}(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
in_boolean_context: {
|
in_boolean_context: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
|
|||||||
@@ -6,3 +6,71 @@ non_ascii_function_identifier_name: {
|
|||||||
}
|
}
|
||||||
expect_exact: "function fooλ(δλ){}function λ(δλ){}(function λ(δλ){})();"
|
expect_exact: "function fooλ(δλ){}function λ(δλ){}(function λ(δλ){})();"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iifes_returning_constants_keep_fargs_true: {
|
||||||
|
options = {
|
||||||
|
keep_fargs : true,
|
||||||
|
side_effects : true,
|
||||||
|
evaluate : true,
|
||||||
|
unused : true,
|
||||||
|
dead_code : true,
|
||||||
|
conditionals : true,
|
||||||
|
comparisons : true,
|
||||||
|
booleans : true,
|
||||||
|
if_return : true,
|
||||||
|
join_vars : true,
|
||||||
|
reduce_vars : true,
|
||||||
|
cascade : true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(){ return -1.23; }());
|
||||||
|
console.log( function foo(){ return "okay"; }() );
|
||||||
|
console.log( function foo(x, y, z){ return 123; }() );
|
||||||
|
console.log( function(x, y, z){ return z; }() );
|
||||||
|
console.log( function(x, y, z){ if (x) return y; return z; }(1, 2, 3) );
|
||||||
|
console.log( function(x, y){ return x * y; }(2, 3) );
|
||||||
|
console.log( function(x, y){ return x * y; }(2, 3, a(), b()) );
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("okay");
|
||||||
|
console.log(123);
|
||||||
|
console.log(void 0);
|
||||||
|
console.log(function(x,y,z){return 2}(1,2,3));
|
||||||
|
console.log(function(x,y){return 6}(2,3));
|
||||||
|
console.log(function(x, y){return 6}(2,3,a(),b()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
iifes_returning_constants_keep_fargs_false: {
|
||||||
|
options = {
|
||||||
|
keep_fargs : false,
|
||||||
|
side_effects : true,
|
||||||
|
evaluate : true,
|
||||||
|
unused : true,
|
||||||
|
dead_code : true,
|
||||||
|
conditionals : true,
|
||||||
|
comparisons : true,
|
||||||
|
booleans : true,
|
||||||
|
if_return : true,
|
||||||
|
join_vars : true,
|
||||||
|
reduce_vars : true,
|
||||||
|
cascade : true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(){ return -1.23; }());
|
||||||
|
console.log( function foo(){ return "okay"; }() );
|
||||||
|
console.log( function foo(x, y, z){ return 123; }() );
|
||||||
|
console.log( function(x, y, z){ return z; }() );
|
||||||
|
console.log( function(x, y, z){ if (x) return y; return z; }(1, 2, 3) );
|
||||||
|
console.log( function(x, y){ return x * y; }(2, 3) );
|
||||||
|
console.log( function(x, y){ return x * y; }(2, 3, a(), b()) );
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("okay");
|
||||||
|
console.log(123);
|
||||||
|
console.log(void 0);
|
||||||
|
console.log(2);
|
||||||
|
console.log(6);
|
||||||
|
console.log(function(){return 6}(a(),b()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -213,6 +213,30 @@ evaluate: {
|
|||||||
a();
|
a();
|
||||||
for(;;)
|
for(;;)
|
||||||
c();
|
c();
|
||||||
d();
|
// rule disabled due to issue_1532
|
||||||
|
do d(); while (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_1532: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
loops: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(x, y) {
|
||||||
|
do {
|
||||||
|
if (x) break;
|
||||||
|
foo();
|
||||||
|
} while (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(x, y) {
|
||||||
|
do {
|
||||||
|
if (x) break;
|
||||||
|
foo();
|
||||||
|
} while (false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ negate_iife_3: {
|
|||||||
conditionals: true
|
conditionals: true
|
||||||
};
|
};
|
||||||
input: {
|
input: {
|
||||||
(function(){ return true })() ? console.log(true) : console.log(false);
|
(function(){ return t })() ? console.log(true) : console.log(false);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!function(){ return true }() ? console.log(false) : console.log(true);
|
!function(){ return t }() ? console.log(false) : console.log(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,10 +51,10 @@ negate_iife_3_off: {
|
|||||||
conditionals: true,
|
conditionals: true,
|
||||||
};
|
};
|
||||||
input: {
|
input: {
|
||||||
(function(){ return true })() ? console.log(true) : console.log(false);
|
(function(){ return t })() ? console.log(true) : console.log(false);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!function(){ return true }() ? console.log(false) : console.log(true);
|
!function(){ return t }() ? console.log(false) : console.log(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,13 +65,13 @@ negate_iife_4: {
|
|||||||
sequences: true
|
sequences: true
|
||||||
};
|
};
|
||||||
input: {
|
input: {
|
||||||
(function(){ return true })() ? console.log(true) : console.log(false);
|
(function(){ return t })() ? console.log(true) : console.log(false);
|
||||||
(function(){
|
(function(){
|
||||||
console.log("something");
|
console.log("something");
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!function(){ return true }() ? console.log(false) : console.log(true), function(){
|
!function(){ return t }() ? console.log(false) : console.log(true), function(){
|
||||||
console.log("something");
|
console.log("something");
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ sequence_off: {
|
|||||||
};
|
};
|
||||||
input: {
|
input: {
|
||||||
function f() {
|
function f() {
|
||||||
(function(){ return true })() ? console.log(true) : console.log(false);
|
(function(){ return t })() ? console.log(true) : console.log(false);
|
||||||
(function(){
|
(function(){
|
||||||
console.log("something");
|
console.log("something");
|
||||||
})();
|
})();
|
||||||
@@ -95,19 +95,19 @@ sequence_off: {
|
|||||||
(function(){
|
(function(){
|
||||||
console.log("something");
|
console.log("something");
|
||||||
})();
|
})();
|
||||||
(function(){ return true })() ? console.log(true) : console.log(false);
|
(function(){ return t })() ? console.log(true) : console.log(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f() {
|
function f() {
|
||||||
!function(){ return true }() ? console.log(false) : console.log(true), function(){
|
!function(){ return t }() ? console.log(false) : console.log(true), function(){
|
||||||
console.log("something");
|
console.log("something");
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
function g() {
|
function g() {
|
||||||
(function(){
|
(function(){
|
||||||
console.log("something");
|
console.log("something");
|
||||||
})(), function(){ return true }() ? console.log(true) : console.log(false);
|
})(), function(){ return t }() ? console.log(true) : console.log(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ negate_iife_5: {
|
|||||||
conditionals: true,
|
conditionals: true,
|
||||||
};
|
};
|
||||||
input: {
|
input: {
|
||||||
if ((function(){ return true })()) {
|
if ((function(){ return t })()) {
|
||||||
foo(true);
|
foo(true);
|
||||||
} else {
|
} else {
|
||||||
bar(false);
|
bar(false);
|
||||||
@@ -129,7 +129,7 @@ negate_iife_5: {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!function(){ return true }() ? bar(false) : foo(true), function(){
|
!function(){ return t }() ? bar(false) : foo(true), function(){
|
||||||
console.log("something");
|
console.log("something");
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ negate_iife_5_off: {
|
|||||||
conditionals: true,
|
conditionals: true,
|
||||||
};
|
};
|
||||||
input: {
|
input: {
|
||||||
if ((function(){ return true })()) {
|
if ((function(){ return t })()) {
|
||||||
foo(true);
|
foo(true);
|
||||||
} else {
|
} else {
|
||||||
bar(false);
|
bar(false);
|
||||||
@@ -152,7 +152,7 @@ negate_iife_5_off: {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!function(){ return true }() ? bar(false) : foo(true), function(){
|
!function(){ return t }() ? bar(false) : foo(true), function(){
|
||||||
console.log("something");
|
console.log("something");
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -563,7 +563,7 @@ inner_var_for: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inner_var_for_in: {
|
inner_var_for_in_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
@@ -589,3 +589,54 @@ inner_var_for_in: {
|
|||||||
x(1, b, c, d);
|
x(1, b, c, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inner_var_for_in_2: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
for (var long_name in {})
|
||||||
|
console.log(long_name);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
for (var long_name in {})
|
||||||
|
console.log(long_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_1533_1: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var id = "";
|
||||||
|
for (id in {break: "me"})
|
||||||
|
console.log(id);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var id = "";
|
||||||
|
for (id in {break: "me"})
|
||||||
|
console.log(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_1533_2: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var id = "";
|
||||||
|
for (var id in {break: "me"})
|
||||||
|
console.log(id);
|
||||||
|
console.log(id);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var id = "";
|
||||||
|
for (var id in {break: "me"})
|
||||||
|
console.log(id);
|
||||||
|
console.log(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ describe("minify", function() {
|
|||||||
assert.strictEqual(code, "// comment1 comment2\nbar();");
|
assert.strictEqual(code, "// comment1 comment2\nbar();");
|
||||||
});
|
});
|
||||||
it("should not drop #__PURE__ hint if function is retained", function() {
|
it("should not drop #__PURE__ hint if function is retained", function() {
|
||||||
var result = Uglify.minify("var a = /*#__PURE__*/(function(){return 1})();", {
|
var result = Uglify.minify("var a = /*#__PURE__*/(function(){ foo(); })();", {
|
||||||
fromString: true,
|
fromString: true,
|
||||||
output: {
|
output: {
|
||||||
comments: "all",
|
comments: "all",
|
||||||
@@ -163,7 +163,7 @@ describe("minify", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
var code = result.code;
|
var code = result.code;
|
||||||
assert.strictEqual(code, "var a=/*#__PURE__*/function(){return 1}();");
|
assert.strictEqual(code, "var a=/*#__PURE__*/function(){foo()}();");
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user