From 62763e6b160e1daa83a65e19dcd1790bf094cf99 Mon Sep 17 00:00:00 2001 From: miripiruni Date: Mon, 18 Jan 2016 12:22:09 +0300 Subject: [PATCH] Port of 0872a8b (#164): should ignore empty string as modName and elemModName --- lib/bemhtml/runtime/index.js | 4 +++- test/runtime-test.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/bemhtml/runtime/index.js b/lib/bemhtml/runtime/index.js index 685b779b..bb8017c7 100644 --- a/lib/bemhtml/runtime/index.js +++ b/lib/bemhtml/runtime/index.js @@ -633,8 +633,10 @@ BEMHTML.prototype.buildModsClasses = function buildModsClasses(block, var res = ''; var modName; + + /*jshint -W089 */ for (modName in mods) { - if (!mods.hasOwnProperty(modName)) + if (!mods.hasOwnProperty(modName) || modName === '') continue; var modVal = mods[modName]; diff --git a/test/runtime-test.js b/test/runtime-test.js index 77d7ffcf..095831eb 100644 --- a/test/runtime-test.js +++ b/test/runtime-test.js @@ -789,6 +789,20 @@ describe('BEMHTML compiler/Runtime', function() { }); }); + describe('elem', function() { + it('should ignore empty string as modName values', function() { + test(function() { + }, { block: 'a', mods: { '': 'b' } }, + '
'); + }); + + it('should ignore empty string as elemModName values', function() { + test(function() { + }, { block: 'a', elem: 'b', elemMods: { '': 'c' } }, + '
'); + }); + }); + describe('wildcard elem', function() { it('should be called before the matched templates', function () { test(function() {