bem / bh

BH template engine
http://bem.github.io/bh/
MIT License
68 stars 31 forks source link

Strange matching rules #66

Closed floatdrop closed 10 years ago

floatdrop commented 10 years ago

I have found very "strange" behavior of matching rules. Suppose I have such setup of bh:

bh.match('block__elem', function () { console.log('block__elem'); });
bh.match('block__elem_emod', function () { console.log('block__elem_emod'); });
bh.match('block__elem_mod', function () { console.log('block__elem_mod'); });
bh.match('block_mod__elem', function () { console.log('block_mod__elem'); });
bh.match('block_emod__elem', function () { console.log('block_emod__elem'); });
bh.match('block_mod__elem_emod', function () { console.log('block_mod__elem_emod'); });

And applying them with this code:

console.log(bh.apply({block: 'block', elem: 'elem', mods: { mod: true, emod: true } }));

Which gives me this HTML:

<div class="block__elem block__elem_mod block__elem_emod"></div>

As you can see, HTML contains only three classes, but output of a program is:

block_mod__elem_emod
block_emod__elem
block_mod__elem
block__elem_mod
block__elem_emod
block__elem

Which indicates, that all six matchers has been applied. Is this expected behaviour?

mishanga commented 10 years ago

For now this is expected behaviour. You should use elemMods instead of mods in bemjson. I'll fix it in 3.0.0.

floatdrop commented 10 years ago

Any ETA on 3.0 release?

mishanga commented 10 years ago

September, 2014