minor clean-ups (#5701)
This commit is contained in:
@@ -76,7 +76,7 @@ function OutputStream(options) {
|
||||
wrap_iife : false,
|
||||
}, true);
|
||||
|
||||
// Convert comment option to RegExp if neccessary and set up comments filter
|
||||
// Convert comment option to RegExp if necessary and set up comments filter
|
||||
var comment_filter = return_false; // Default case, throw all comments away
|
||||
if (options.comments) {
|
||||
var comments = options.comments;
|
||||
@@ -997,7 +997,7 @@ function OutputStream(options) {
|
||||
if (self.init instanceof AST_Definitions) {
|
||||
self.init.print(output);
|
||||
} else {
|
||||
parenthesize_for_noin(self.init, output, true);
|
||||
parenthesize_for_no_in(self.init, output, true);
|
||||
}
|
||||
output.print(";");
|
||||
output.space();
|
||||
@@ -1413,7 +1413,7 @@ function OutputStream(options) {
|
||||
print_braced(this, output);
|
||||
});
|
||||
|
||||
function print_definitinos(type) {
|
||||
function print_definitions(type) {
|
||||
return function(output) {
|
||||
var self = this;
|
||||
output.print(type);
|
||||
@@ -1426,15 +1426,15 @@ function OutputStream(options) {
|
||||
if (!(p instanceof AST_IterationStatement && p.init === self)) output.semicolon();
|
||||
};
|
||||
}
|
||||
DEFPRINT(AST_Const, print_definitinos("const"));
|
||||
DEFPRINT(AST_Let, print_definitinos("let"));
|
||||
DEFPRINT(AST_Var, print_definitinos("var"));
|
||||
DEFPRINT(AST_Const, print_definitions("const"));
|
||||
DEFPRINT(AST_Let, print_definitions("let"));
|
||||
DEFPRINT(AST_Var, print_definitions("var"));
|
||||
|
||||
function parenthesize_for_noin(node, output, noin) {
|
||||
function parenthesize_for_no_in(node, output, no_in) {
|
||||
var parens = false;
|
||||
// need to take some precautions here:
|
||||
// https://github.com/mishoo/UglifyJS/issues/60
|
||||
if (noin) node.walk(new TreeWalker(function(node) {
|
||||
if (no_in) node.walk(new TreeWalker(function(node) {
|
||||
if (parens) return true;
|
||||
if (node instanceof AST_Binary && node.operator == "in") return parens = true;
|
||||
if (node instanceof AST_Scope && !(is_arrow(node) && node.value)) return true;
|
||||
@@ -1450,8 +1450,8 @@ function OutputStream(options) {
|
||||
output.print("=");
|
||||
output.space();
|
||||
var p = output.parent(1);
|
||||
var noin = p instanceof AST_For || p instanceof AST_ForEnumeration;
|
||||
parenthesize_for_noin(self.value, output, noin);
|
||||
var no_in = p instanceof AST_For || p instanceof AST_ForEnumeration;
|
||||
parenthesize_for_no_in(self.value, output, no_in);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user