aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 369094ee..96047291 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -327,7 +327,21 @@ function Compressor(options, false_by_default) {
if (stat instanceof AST_Definitions && prev && prev.TYPE == stat.TYPE) {
prev.definitions = prev.definitions.concat(stat.definitions);
CHANGED = true;
- } else {
+ }
+ else if (stat instanceof AST_For
+ && prev instanceof AST_Definitions
+ && (!stat.init || stat.init.TYPE == prev.TYPE)) {
+ CHANGED = true;
+ a.pop();
+ if (stat.init) {
+ stat.init.definitions = prev.definitions.concat(stat.init.definitions);
+ } else {
+ stat.init = prev;
+ }
+ a.push(stat);
+ prev = stat;
+ }
+ else {
prev = stat;
a.push(stat);
}