Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[major] BEM-XJST: block(*) should not apply to elems #455

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/bemxjst/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ BEMXJST.prototype.transformEntities = function(entities) {
entities[key].prepend(wildcard);
}
this.defaultEnt.prepend(wildcard);
this.defaultElemEnt.prepend(wildcard);
}

// Merge wildcard elem templates
Expand Down
17 changes: 14 additions & 3 deletions test/modes-block-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@ describe('Modes block(blockName)', function() {
},
[
{ content: 'foo' },
{ block: 'b' },
{ block: 'input', elem: 'control' }
{ block: 'a' },
{ block: 'b' }
],
'<b>foo</b><b class="b"></b><b class="input__control"></b>');
'<b>foo</b><b class="a"></b><b class="b"></b>');
});

it('should’t apply block(*) to elems', function() {
test(function() {
block('*').tag()('b');
},
[
{ block: 'a' },
{ block: 'b', elem: 'e' }
],
'<b class="a"></b><div class="b__e"></div>');
});

it('block(*) should be called before the matched templates', function() {
Expand Down
14 changes: 14 additions & 0 deletions test/modes-elem-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ describe('Modes elem(elemName)', function() {
'<b class="b__inner">test</b></b>');
});

it('apply template to all blocks and elems', function() {
test(function() {
var toAll = function() { return 'span'; };

block('*').tag()(toAll);
block('*').elem('*').tag()(toAll);
},
[
{ block: 'a' },
{ block: 'b', elem: 'e' }
],
'<span class="a"></span><span class="b__e"></span>');
});

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