From 88f3160c37e26258d0fbac284380e68113be4f38 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Mon, 20 Apr 2015 17:06:24 +0200 Subject: [PATCH] lib: do not render `undefined` --- lib/bemhtml/runtime/index.js | 2 ++ test/api-test.js | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/bemhtml/runtime/index.js b/lib/bemhtml/runtime/index.js index 8719f740..bd4305dd 100644 --- a/lib/bemhtml/runtime/index.js +++ b/lib/bemhtml/runtime/index.js @@ -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 + ''; diff --git a/test/api-test.js b/test/api-test.js index 9655487b..abc4d464 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -200,4 +200,14 @@ describe('BEMHTML compiler', function() { }, '
' + '
'); }); + + it('should not render `undefined`', function () { + test(function() { + }, [ + undefined, + undefined, + { block: 'b1' }, + undefined + ], '
'); + }); });