Skip to content

Commit

Permalink
BEMHTML: fix #303 bug with mix and render
Browse files Browse the repository at this point in the history
  • Loading branch information
miripiruni committed Jul 6, 2016
1 parent 082cc90 commit da8a205
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"unused" : true, // true: Require all defined variables be used
"strict" : false, // true: Requires all functions run in ES5 Strict Mode
"maxparams" : false, // {int} Max number of formal params allowed per function
"maxdepth" : 3, // {int} Max depth of nested blocks (within functions)
"maxdepth" : 4, // {int} Max depth of nested blocks (within functions)
"maxstatements" : false, // {int} Max number statements per function
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
"maxlen" : false, // {int} Max number of characters per line
Expand Down
2 changes: 2 additions & 0 deletions lib/bemhtml/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ BEMHTML.prototype.renderMix = function renderMix(entity,
if (!nestedItem.block &&
!nestedItem.elem ||
!visited[classBuilder.build(nestedItem.block, nestedItem.elem)]) {
if (nestedItem.block) continue;

nestedItem._block = block;
nestedItem._elem = elem;
mix = mix.slice(0, i + 1).concat(
Expand Down
20 changes: 20 additions & 0 deletions test/runtime-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,26 @@ describe('BEMHTML compiler/Runtime', function() {
'</a>');
});

it('should render both mix from templates and from bemjson', function() {
test(function() {
block('b').elem('e').replace()(function() {
var mix = [
{ block: this.block, elem: this.elem },
{ block: 'sprite', mods: { test: 'opa' } }
].concat(this.ctx.mix);

return {
block: 'replace',
mix: mix
};
});
}, {
block: 'b',
elem: 'e',
mix: { block: 'bemjson' }
}, '<div class="replace b__e sprite sprite_test_opa bemjson"></div>');
});

it('should check that mix do not overwrite jsParams', function() {
test(function() {
block('b1')(
Expand Down

0 comments on commit da8a205

Please sign in to comment.