Skip to content

Commit

Permalink
lib: do not render undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Apr 20, 2015
1 parent a40cf34 commit 88f3160
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/bemhtml/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ BEMHTML.prototype.runMany = function runMany(arr) {
};

BEMHTML.prototype.runOne = function runOne(context) {
if (context === undefined)
return '';
if (utils.isSimple(context))
return context + '';

Expand Down
10 changes: 10 additions & 0 deletions test/api-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,14 @@ describe('BEMHTML compiler', function() {
}, '<div class="b2"><div class="b1"><div class="b1__e1"></div></div>' +
'<div class="b2__e1"></div></div>');
});

it('should not render `undefined`', function () {
test(function() {
}, [
undefined,
undefined,
{ block: 'b1' },
undefined
], '<div class="b1"></div>');
});
});

0 comments on commit 88f3160

Please sign in to comment.