From 8262070f5c7ce7e623c8f9bd4fc19cdf024cd7ba Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Thu, 22 Jul 2010 14:08:07 -0700 Subject: [PATCH] fixing extra spaces in nested empty functions. Issue #527 --- lib/lexer.js | 2 +- lib/nodes.js | 4 ++-- lib/rewriter.js | 2 +- src/nodes.coffee | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/lexer.js b/lib/lexer.js index f9f9a009..1fa546ad 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -17,7 +17,7 @@ starts = _c.starts; compact = _c.compact; exports.Lexer = (function() { - Lexer = function() { }; + Lexer = function() {}; Lexer.prototype.tokenize = function(code, options) { var o; code = code.replace(/(\r|\s+$)/g, ''); diff --git a/lib/nodes.js b/lib/nodes.js index ab482ff6..c886cb51 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -26,7 +26,7 @@ starts = _a.starts; ends = _a.ends; exports.BaseNode = (function() { - BaseNode = function() { }; + BaseNode = function() {}; BaseNode.prototype.compile = function(o) { var closure, top; this.options = merge(o || {}); @@ -984,7 +984,7 @@ (o.scope.parameter(param)); } code = this.body.expressions.length ? ("\n" + (this.body.compileWithDeclarations(o)) + "\n") : ''; - func = ("function(" + (params.join(', ')) + ") {" + code + (this.idt(this.bound ? 1 : 0)) + "}"); + func = ("function(" + (params.join(', ')) + ") {" + code + (code && this.idt(this.bound ? 1 : 0)) + "}"); if (top && !this.bound) { func = ("(" + func + ")"); } diff --git a/lib/rewriter.js b/lib/rewriter.js index 267b641a..a63784a2 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -11,7 +11,7 @@ _b = helpers; include = _b.include; exports.Rewriter = (function() { - Rewriter = function() { }; + Rewriter = function() {}; Rewriter.prototype.rewrite = function(tokens) { this.tokens = tokens; this.adjustComments(); diff --git a/src/nodes.coffee b/src/nodes.coffee index fdba1cad..899036f2 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -882,7 +882,7 @@ exports.CodeNode: class CodeNode extends BaseNode @body.makeReturn() (o.scope.parameter(param)) for param in params code: if @body.expressions.length then "\n${ @body.compileWithDeclarations(o) }\n" else '' - func: "function(${ params.join(', ') }) {$code${@idt(if @bound then 1 else 0)}}" + func: "function(${ params.join(', ') }) {$code${ code and @idt(if @bound then 1 else 0) }}" func: "($func)" if top and not @bound return func unless @bound inner: "(function() {\n${@idt(2)}return __func.apply(__this, arguments);\n${@idt(1)}});"