(blockStmt *js.BlockStmt)
| 424 | } |
| 425 | |
| 426 | func (m *jsMinifier) minifyBlockAsStmt(blockStmt *js.BlockStmt) { |
| 427 | // minify block when statement is expected, i.e. semicolon if empty or remove braces for single statement |
| 428 | // assume we already renamed the scope |
| 429 | hasLexicalVars := false |
| 430 | for _, v := range blockStmt.Scope.Declared[blockStmt.Scope.NumForDecls:] { |
| 431 | if v.Decl == js.LexicalDecl { |
| 432 | hasLexicalVars = true |
| 433 | break |
| 434 | } |
| 435 | } |
| 436 | if 1 < len(blockStmt.List) || hasLexicalVars { |
| 437 | m.minifyBlockStmt(blockStmt) |
| 438 | } else if len(blockStmt.List) == 1 { |
| 439 | m.minifyStmt(blockStmt.List[0]) |
| 440 | } else { |
| 441 | m.write(semicolonBytes) |
| 442 | m.needsSemicolon = false |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | func (m *jsMinifier) minifyStmtOrBlock(i js.IStmt, blockType blockType) { |
| 447 | // minify stmt or a block |
no test coverage detected