Skip to content

Commit

Permalink
Port of 0872a8b (#164): should ignore empty string as modName and ele…
Browse files Browse the repository at this point in the history
…mModName
  • Loading branch information
miripiruni committed Jan 18, 2016
1 parent e11506e commit 62763e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/bemhtml/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
14 changes: 14 additions & 0 deletions test/runtime-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' } },
'<div class="a"></div>');
});

it('should ignore empty string as elemModName values', function() {
test(function() {
}, { block: 'a', elem: 'b', elemMods: { '': 'c' } },
'<div class="a__b"></div>');
});
});

describe('wildcard elem', function() {
it('should be called before the matched templates', function () {
test(function() {
Expand Down

0 comments on commit 62763e6

Please sign in to comment.