Skip to content

Commit

Permalink
class-builder: elem === '' means no elem
Browse files Browse the repository at this point in the history
Fix: #152
  • Loading branch information
indutny committed Dec 22, 2015
1 parent 199c068 commit 6c427cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bemxjst/class-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function ClassBuilder(options) {
exports.ClassBuilder = ClassBuilder;

ClassBuilder.prototype.build = function build(block, elem) {
if (elem === undefined)
if (!elem)
return block;
else
return block + this.elemDelim + elem;
Expand Down
11 changes: 11 additions & 0 deletions test/bemhtml/runtime-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ describe('BEMHTML compiler/Runtime', function() {
], '<div class="b1"></div>');
});

it('should assume elem=\'\' is a falsey value', function () {
test(function() {
block('b1').elem('e1').def()(function() {
return applyCtx(this.extend(this.ctx, {
block: 'b2',
elem: ''
}));
});
}, { block: 'b1' }, '<div class="b1"></div>');
});

it('should properly save context while render plain html items', function() {
test(function() {
}, {
Expand Down

0 comments on commit 6c427cc

Please sign in to comment.