Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix #2846

  • Loading branch information...
commit 53a5f26430bdd98e58d8ea6646ec614d29bef470 1 parent 718224f
@vendethiel vendethiel authored
View
5 lib/coffee-script/browser.js
@@ -25,6 +25,7 @@
options = {};
}
options.bare = true;
+ options.shiftLine = true;
return Function(compile(code, options))();
};
@@ -32,7 +33,7 @@
return;
}
- if ((typeof btoa !== "undefined" && btoa !== null) && (typeof JSON !== "undefined" && JSON !== null)) {
+ if ((typeof btoa !== "undefined" && btoa !== null) && (typeof JSON !== "undefined" && JSON !== null) && (typeof unescape !== "undefined" && unescape !== null) && (typeof encodeURIComponent !== "undefined" && encodeURIComponent !== null)) {
compile = function(code, options) {
var js, v3SourceMap, _ref;
if (options == null) {
@@ -41,7 +42,7 @@
options.sourceMap = true;
options.inline = true;
_ref = CoffeeScript.compile(code, options), js = _ref.js, v3SourceMap = _ref.v3SourceMap;
- return "" + js + "\n//@ sourceMappingURL=data:application/json;base64," + (btoa(v3SourceMap)) + "\n//@ sourceURL=coffeescript";
+ return "" + js + "\n//@ sourceMappingURL=data:application/json;base64," + (btoa(unescape(encodeURIComponent(v3SourceMap)))) + "\n//@ sourceURL=coffeescript";
};
}
View
5 lib/coffee-script/coffee-script.js
@@ -34,7 +34,10 @@
}
fragments = (parser.parse(lexer.tokenize(code, options))).compileToFragments(options);
currentLine = 0;
- if (options.header || options.inline) {
+ if (options.header) {
+ currentLine += 1;
+ }
+ if (options.shiftLine) {
currentLine += 1;
}
currentColumn = 0;
View
2  lib/coffee-script/nodes.js
@@ -2125,7 +2125,7 @@
set = '';
body = this.body;
if (body.isEmpty()) {
- body = '';
+ body = this.makeCode('');
} else {
if (this.returns) {
body.makeReturn(rvar = o.scope.freeVariable('results'));
View
2  src/nodes.coffee
@@ -1504,7 +1504,7 @@ exports.While = class While extends Base
set = ''
{body} = this
if body.isEmpty()
- body = ''
+ body = @makeCode ''
else
if @returns
body.makeReturn rvar = o.scope.freeVariable 'results'
View
3  test/compilation.coffee
@@ -76,3 +76,6 @@ test "#1055: invalid keys in real (but not work-product) objects", ->
test "#1066: interpolated strings are not implicit functions", ->
cantCompile '"int#{er}polated" arg'
+
+test "#2846: while with empty body", ->
+ CoffeeScript.compile 'while 1 then', {sourceMap: true}
Please sign in to comment.
Something went wrong with that request. Please try again.