Skip to content

Commit

Permalink
BEMHTML: fix render i-bem when mix elem with js (fix #441)
Browse files Browse the repository at this point in the history
  • Loading branch information
miripiruni committed Apr 28, 2017
1 parent 8afc310 commit 808469f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/bemhtml/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ BEMHTML.prototype.renderMix = function(entity, mix, jsParams, addJSInitClass) {
js[classBuilder.build(block, item.elem)] =
item.js === true ? {} : item.js;
if (!addInit)
addInit = block && !item.elem;
addInit = this._elemJsInstances ?
(item.elem || block) :
(block && !item.elem);
}

// Process nested mixes
Expand Down
13 changes: 13 additions & 0 deletions test/bemjson-js-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,17 @@ describe('BEMJSON js', function() {
' data-bem=\'{"b__e":{},"a":{}}\'></div>');
});
});

it('should render i-bem when mixed with elem with js', function() {
compile(function() {}, { elemJsInstances: true })
.apply({
block: 'b',
content: {
elem: 'e1',
mix: { elem: 'e2', js: true }
}
})
.should.equal('<div class="b"><div class="b__e1 b__e2 i-bem" ' +
'data-bem=\'{"b__e2":{}}\'></div></div>');
});
});

0 comments on commit 808469f

Please sign in to comment.