suppress semicolons after do/while (#1556)

- unless both `beautify` & `screw-ie8` are enabled
- deprecate workaround for if-do-while-else

fixes #186
This commit is contained in:
Alex Lam S.L
2017-03-06 17:31:35 +08:00
committed by GitHub
parent a5d62a3fc6
commit a9fc9ddc33
2 changed files with 159 additions and 10 deletions

View File

@@ -784,7 +784,9 @@ function OutputStream(options) {
output.with_parens(function(){
self.condition.print(output);
});
output.semicolon();
if (output.option("beautify") && output.option("screw_ie8")) {
output.semicolon();
}
});
DEFPRINT(AST_While, function(self, output){
output.print("while");
@@ -917,15 +919,6 @@ function OutputStream(options) {
// adds the block brackets if needed.
if (!self.body)
return output.force_semicolon();
if (self.body instanceof AST_Do) {
// Unconditionally use the if/do-while workaround for all browsers.
// https://github.com/mishoo/UglifyJS/issues/#issue/57 IE
// croaks with "syntax error" on code like this: if (foo)
// do ... while(cond); else ... we need block brackets
// around do/while
make_block(self.body, output);
return;
}
var b = self.body;
while (true) {
if (b instanceof AST_If) {