Closed floatdrop closed 10 years ago
I have found very "strange" behavior of matching rules. Suppose I have such setup of bh:
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?
For now this is expected behaviour. You should use elemMods instead of mods in bemjson. I'll fix it in 3.0.0.
elemMods
mods
Any ETA on 3.0 release?
September, 2014
I have found very "strange" behavior of matching rules. Suppose I have such setup of
bh
:And applying them with this code:
Which gives me this HTML:
As you can see, HTML contains only three classes, but output of a program is:
Which indicates, that all six matchers has been applied. Is this expected behaviour?