Skip to content

Commit

Permalink
JS: optimize statement lists in labelled staments
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Jun 4, 2022
1 parent ccc7b83 commit 3a6f1f6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (m *jsMinifier) minifyStmt(i js.IStmt) {
case *js.LabelledStmt:
m.write(stmt.Label)
m.write(colonBytes)
m.minifyStmt(stmt.Value)
m.minifyStmtOrBlock(stmt.Value, defaultBlock)
case *js.BranchStmt:
m.write(stmt.Type.Bytes())
if stmt.Label != nil {
Expand Down
1 change: 1 addition & 0 deletions js/js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func TestJS(t *testing.T) {
{`if(!a&&!b){return true}else if(!a||!b){return false}return c&&d`, `return!a&&!b||!!a&&!!b&&c&&d`},
{`if(!a){if(b){throw c}else{return c}}else{return a}`, `if(a)return a;if(b)throw c;return c`},
{`if(!a){return y}else if(b){if(c){return x}}return z`, `return a?b&&c?x:z:y`},
{`if(a)b:{if(c)break b}else if(d)e()`, `if(a){b:if(c)break b}else d&&e()`},

// var declarations
{`var a;var b;a,b`, `var a,b;a,b`},
Expand Down

0 comments on commit 3a6f1f6

Please sign in to comment.