Skip to content

Commit 79f21dd

Browse files
committed
fix root node templating around whitespace
2 parents 5c0e6e5 + 664a516 commit 79f21dd

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

parse.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,11 @@ var actuallyEqualOps = function(wasLower, wasHigher) {
250250

251251

252252
var pullRoot = function(tokens) {
253-
var template = R.repeatN('#', tokens.length || 0).join('');
253+
var template = '';
254254
if (lex.check(tokens[0], {token: 'space'})) {
255255
template = tokens.shift().repr + template;
256256
}
257+
template += R.repeatN('#', tokens.length || 0).join('');
257258
return astNode('expr', tokens, {template: template});
258259
};
259260

test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ describe('Parser', function() {
323323

324324
describe('Echo compiler', function() {
325325
describe('on simple minimal-node ASTs', function() {
326+
it('should work on just whitespace', function() {
327+
assert.equal(compileE(' '), ' ');
328+
});
326329
it('should work for literals', function() {
327330
assert.equal(compileE('1'), '1');
328331
});

0 commit comments

Comments
 (0)