Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Кажется странный приоритет lazyInit #1576

Closed
belozer opened this issue Jun 6, 2018 · 0 comments · Fixed by #1579
Closed

Кажется странный приоритет lazyInit #1576

belozer opened this issue Jun 6, 2018 · 0 comments · Fixed by #1579

Comments

@belozer
Copy link
Member

belozer commented Jun 6, 2018

https://github.com/bem/bem-core/blob/v4/common.blocks/i-bem-dom/i-bem-dom.js#L156

    if(!entityCls.lazyInit || ignoreLazyInit || params.lazyInit === false) {
        ignoreLazyInit && domElem.addClass(BEM_CLASS_NAME); // add css class for preventing memory leaks in further destructing

        entity = new entityCls(uniqIdToDomElems[uniqId], params, !!ignoreLazyInit);
        delete uniqIdToDomElems[uniqId];
        callback && callback.apply(entity, slice.call(arguments, 4));
        return entity;
    }

Невозможно сделать lazyInit : true на определённом блоке из html.

Как вариант, можно переписать условие так

if(ignoreLazyInit || params.lazyInit === false || !entityCls.lazyInit && !params.lazyInit)
   
}

В добавок через lazyInit в модификаторе можно сломать поведение базового блока.

const Block = bemDom.declBlock('block', null, { lazyInit : false });
const Mod = Block.declMod({ modName : 'mod' }, null, { lazyInit : true });
  
console.log(Block.lazyInit, Mod.lazyInit);  true true

Предлагаю запретить использование lazyInit в declMod.

@belozer belozer changed the title Кажется странный кейс lazyInit Кажется странный приоритет lazyInit Jun 6, 2018
@belozer belozer mentioned this issue Jun 19, 2018
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant