Skip to content

Commit

Permalink
tweak beautify output (#5044)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Jul 3, 2021
1 parent 1b74549 commit 668f966
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
15 changes: 6 additions & 9 deletions lib/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,6 @@ function OutputStream(options) {
DEFPRINT(AST_Do, function(output) {
var self = this;
output.print("do");
output.space();
make_block(self.body, output);
output.space();
output.print("while");
Expand All @@ -997,7 +996,6 @@ function OutputStream(options) {
output.with_parens(function() {
self.condition.print(output);
});
output.space();
force_statement(self.body, output);
});
DEFPRINT(AST_For, function(output) {
Expand Down Expand Up @@ -1027,7 +1025,6 @@ function OutputStream(options) {
self.step.print(output);
}
});
output.space();
force_statement(self.body, output);
});
function print_for_enum(prefix, infix) {
Expand All @@ -1042,7 +1039,6 @@ function OutputStream(options) {
output.space();
self.object.print(output);
});
output.space();
force_statement(self.body, output);
};
}
Expand All @@ -1056,7 +1052,6 @@ function OutputStream(options) {
output.with_parens(function() {
self.expression.print(output);
});
output.space();
force_statement(self.body, output);
});
DEFPRINT(AST_ExportDeclaration, function(output) {
Expand Down Expand Up @@ -1325,16 +1320,16 @@ function OutputStream(options) {
output.with_parens(function() {
self.condition.print(output);
});
output.space();
if (self.alternative) {
make_then(self, output);
output.space();
output.print("else");
output.space();
if (self.alternative instanceof AST_If)
if (self.alternative instanceof AST_If) {
output.space();
self.alternative.print(output);
else
} else {
force_statement(self.alternative, output);
}
} else {
force_statement(self.body, output);
}
Expand Down Expand Up @@ -1836,6 +1831,7 @@ function OutputStream(options) {
} else if (stat instanceof AST_EmptyStatement) {
output.force_semicolon();
} else {
output.space();
stat.print(output);
}
}
Expand Down Expand Up @@ -1884,6 +1880,7 @@ function OutputStream(options) {
}

function make_block(stmt, output) {
output.space();
if (stmt instanceof AST_EmptyStatement) {
print_braced_empty(stmt, output);
} else if (stmt instanceof AST_BlockStatement) {
Expand Down
6 changes: 3 additions & 3 deletions test/compress/drop-unused.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,9 +795,9 @@ issue_1656: {
beautify: true,
}
input: {
for(var a=0;;);
for (var a=0;;);
}
expect_exact: "for (;;) ;"
expect_exact: "for (;;);"
}

issue_1709: {
Expand Down Expand Up @@ -1110,7 +1110,7 @@ issue_1838: {
}
expect_exact: [
"function f() {",
" for (a; c; ) ;",
" for (a; c; );",
"}",
]
}
Expand Down

0 comments on commit 668f966

Please sign in to comment.