improve fix for #3856 (#3862)
authorAlex Lam S.L <alexlamsl@gmail.com>
Sat, 9 May 2020 00:50:25 +0000 (01:50 +0100)
committerGitHub <noreply@github.com>
Sat, 9 May 2020 00:50:25 +0000 (08:50 +0800)
lib/compress.js

index 09eaacb..fb4836b 100644 (file)
@@ -2575,12 +2575,11 @@ merge(Compressor.prototype, {
                         if (!declarations_only(node)) return node;
                         defs.definitions = defs.definitions.concat(node.definitions);
                         CHANGED = true;
+                        if (parent instanceof AST_For && parent.init === node) return null;
                         return in_list ? List.skip : make_node(AST_EmptyStatement, node);
                     }
                     if (node instanceof AST_Scope) return node;
                     if (!(node instanceof AST_Statement)) return node;
-                }, function(node) {
-                    if (node instanceof AST_For && is_empty(node.init)) node.init = null;
                 }));
             }
         }