@@ -2513,7 +2513,7 @@ merge(Compressor.prototype, {
|
||||
var line = block.body[i];
|
||||
if (line instanceof AST_Var && declarations_only(line)) {
|
||||
decls.push(line);
|
||||
} else if (stat) {
|
||||
} else if (stat || line instanceof AST_Const) {
|
||||
return false;
|
||||
} else {
|
||||
stat = line;
|
||||
|
||||
@@ -990,7 +990,7 @@ function OutputStream(options) {
|
||||
/* -----[ if ]----- */
|
||||
function make_then(self, output) {
|
||||
var b = self.body;
|
||||
if (output.option("braces")
|
||||
if (output.option("braces") && !(b instanceof AST_Const)
|
||||
|| output.option("ie8") && b instanceof AST_Do)
|
||||
return make_block(b, output);
|
||||
// The squeezer replaces "block"-s that contain only a single
|
||||
@@ -1381,7 +1381,7 @@ function OutputStream(options) {
|
||||
});
|
||||
|
||||
function force_statement(stat, output) {
|
||||
if (output.option("braces")) {
|
||||
if (output.option("braces") && !(stat instanceof AST_Const)) {
|
||||
make_block(stat, output);
|
||||
} else if (!stat || stat instanceof AST_EmptyStatement) {
|
||||
output.force_semicolon();
|
||||
|
||||
@@ -1056,3 +1056,51 @@ issue_4216: {
|
||||
}
|
||||
expect_stdout: true
|
||||
}
|
||||
|
||||
skip_braces: {
|
||||
beautify = {
|
||||
beautify: true,
|
||||
braces: true,
|
||||
}
|
||||
input: {
|
||||
if (console)
|
||||
const a = 42;
|
||||
else
|
||||
const b = null;
|
||||
console.log(typeof a, typeof b);
|
||||
}
|
||||
expect_exact: [
|
||||
"if (console) const a = 42; else const b = null;",
|
||||
"",
|
||||
"console.log(typeof a, typeof b);",
|
||||
]
|
||||
expect_stdout: true
|
||||
}
|
||||
|
||||
issue_4220: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
conditionals: true,
|
||||
sequences: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
if (console) {
|
||||
var o = console;
|
||||
for (var k in o);
|
||||
} else {
|
||||
const a = 0;
|
||||
}
|
||||
console.log(typeof a);
|
||||
}
|
||||
expect: {
|
||||
if (console) {
|
||||
var o;
|
||||
for (var k in console);
|
||||
} else {
|
||||
const a = 0;
|
||||
}
|
||||
console.log(typeof a);
|
||||
}
|
||||
expect_stdout: true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user