Last active
August 29, 2015 14:12
-
-
Save rvanvelzen/d77c6ab9bf9f06e669b8 to your computer and use it in GitHub Desktop.
Patch for UglifyJS2#502
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/output.js b/lib/output.js | |
index 7fe61af..c6752ae 100644 | |
--- a/lib/output.js | |
+++ b/lib/output.js | |
@@ -890,17 +890,29 @@ function OutputStream(options) { | |
/* -----[ var/const ]----- */ | |
AST_Definitions.DEFMETHOD("_do_print", function(output, kind){ | |
- output.print(kind); | |
- output.space(); | |
- this.definitions.forEach(function(def, i){ | |
- if (i) output.comma(); | |
- def.print(output); | |
- }); | |
var p = output.parent(); | |
var in_for = p instanceof AST_For || p instanceof AST_ForIn; | |
var avoid_semicolon = in_for && p.init === this; | |
- if (!avoid_semicolon) | |
- output.semicolon(); | |
+ | |
+ if (!avoid_semicolon) { | |
+ this.definitions.forEach(function(def, i){ | |
+ if (i) { | |
+ output.newline(); | |
+ output.indent(); | |
+ } | |
+ output.print(kind); | |
+ output.space(); | |
+ def.print(output); | |
+ output.semicolon(); | |
+ }); | |
+ } else { | |
+ output.print(kind); | |
+ output.space(); | |
+ this.definitions.forEach(function(def, i){ | |
+ if (i) output.comma(); | |
+ def.print(output); | |
+ }); | |
+ } | |
}); | |
DEFPRINT(AST_Var, function(self, output){ | |
self._do_print(output, "var"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment