diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-07-03 16:10:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-03 23:10:39 +0800 |
commit | 668f96623c745a4255766fe5595f1a95052afb77 (patch) | |
tree | 0b16b7875bb367a0ce4a89d52c9b736b88665744 | |
parent | 1b745494ce12840176439b947acefbd63aa9d5d2 (diff) | |
download | tracifyjs-668f96623c745a4255766fe5595f1a95052afb77.tar.gz tracifyjs-668f96623c745a4255766fe5595f1a95052afb77.zip |
tweak `beautify` output (#5044)
-rw-r--r-- | lib/output.js | 15 | ||||
-rw-r--r-- | test/compress/drop-unused.js | 6 |
2 files changed, 9 insertions, 12 deletions
diff --git a/lib/output.js b/lib/output.js index 4f530038..33a1b6c8 100644 --- a/lib/output.js +++ b/lib/output.js @@ -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"); @@ -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) { @@ -1027,7 +1025,6 @@ function OutputStream(options) { self.step.print(output); } }); - output.space(); force_statement(self.body, output); }); function print_for_enum(prefix, infix) { @@ -1042,7 +1039,6 @@ function OutputStream(options) { output.space(); self.object.print(output); }); - output.space(); force_statement(self.body, output); }; } @@ -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) { @@ -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); } @@ -1836,6 +1831,7 @@ function OutputStream(options) { } else if (stat instanceof AST_EmptyStatement) { output.force_semicolon(); } else { + output.space(); stat.print(output); } } @@ -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) { diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index 015dec92..4c2ffece 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -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: { @@ -1110,7 +1110,7 @@ issue_1838: { } expect_exact: [ "function f() {", - " for (a; c; ) ;", + " for (a; c; );", "}", ] } |