bem / bh

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

isFirst() is not working correctly #48

Closed shuhrat closed 10 years ago

shuhrat commented 10 years ago

I have an bemjson object, it contains an array which first element is false or undefined

{ 
    block: 'button', 
    content: [
        false, // can olso be undefined
        { elem: 'inner' },
        { elem: 'inner' },
        { elem: 'inner' }
    ]
}

and matcher

bh.match('button__inner', function(ctx) {
    if (ctx.isFirst()) {
        ctx.mod('first', 'yes');
    }
    if (ctx.isLast()) {
        ctx.mod('last', 'yes');
    }
});

when I apply matcher to the bemjson getting

<div class="button">
  <div class="button__inner"></div>
  <div class="button__inner"></div>
  <div class="button__inner button__inner_last_yes"></div>
</div>

instead of expected

<div class="button">
  <div class="button__inner button__inner_first_yes"></div>
  <div class="button__inner"></div>
  <div class="button__inner button__inner_last_yes"></div>
</div>
mishanga commented 10 years ago

Duplicate of #46