bem / bem-core

BEM Core Library
https://ru.bem.info/technologies/classic/i-bem/
Other
276 stars 95 forks source link

Process all decls in onSetMod on init #1585

Closed belozer closed 6 years ago

belozer commented 6 years ago

Process all decls in onSetMod on init (without declMod)

const CartItem = bemDom.declBlock('CartItem', {
    onSetMod : {
        js : {
            inited() {
                console.log('inited')
            }
        },
        focused : {
            'true'() {
                console.log('focused modifer');
                // Add listeners and find blocks
            },
            ''() { // Stop listeners }
        }
    },
});

cartItem = new CartItem({ 'focused' : true });
console.log(cartItem.getMod('focused'))
cartItem.setMod('focused');

});

in console

inited
true

But want so

focused modifer
inited
true