From a44894966a2c0f180b2304fa1fb8252ba57e858e Mon Sep 17 00:00:00 2001 From: miripiruni Date: Wed, 17 May 2017 17:30:24 +0300 Subject: [PATCH] BEM-XJST: block(*) should not apply to elems (issue #256) --- lib/bemxjst/index.js | 1 - test/modes-block-test.js | 17 ++++++++++++++--- test/modes-elem-test.js | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/bemxjst/index.js b/lib/bemxjst/index.js index a4de7203..f931eb40 100644 --- a/lib/bemxjst/index.js +++ b/lib/bemxjst/index.js @@ -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 diff --git a/test/modes-block-test.js b/test/modes-block-test.js index b3932409..71fa79a9 100644 --- a/test/modes-block-test.js +++ b/test/modes-block-test.js @@ -26,10 +26,21 @@ describe('Modes block(blockName)', function() { }, [ { content: 'foo' }, - { block: 'b' }, - { block: 'input', elem: 'control' } + { block: 'a' }, + { block: 'b' } ], - 'foo'); + 'foo'); + }); + + it('should’t apply block(*) to elems', function() { + test(function() { + block('*').tag()('b'); + }, + [ + { block: 'a' }, + { block: 'b', elem: 'e' } + ], + '
'); }); it('block(*) should be called before the matched templates', function() { diff --git a/test/modes-elem-test.js b/test/modes-elem-test.js index 0a720ebb..901c659c 100644 --- a/test/modes-elem-test.js +++ b/test/modes-elem-test.js @@ -31,6 +31,20 @@ describe('Modes elem(elemName)', function() { 'test'); }); + 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' } + ], + ''); + }); + it('elem(*) should be called before the matched templates', function() { test(function() {