Skip to content

Commit

Permalink
Force lazyInit
Browse files Browse the repository at this point in the history
  • Loading branch information
belozer authored and veged committed Jun 19, 2018
1 parent 7ca3278 commit bc3b130
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common.blocks/i-bem-dom/i-bem-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function initEntity(entityName, domElem, params, ignoreLazyInit, callback) {

entityCls._processInit();

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

entity = new entityCls(uniqIdToDomElems[uniqId], params, !!ignoreLazyInit);
Expand Down
21 changes: 21 additions & 0 deletions common.blocks/i-bem-dom/i-bem-dom.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,27 @@ describe('i-bem-dom', function() {
spy.should.have.been.called;
});

it('should be possible to force lazy initialization', function() {
spy = sinon.spy();

bemDom.declBlock('block', {
onSetMod : {
'js' : {
'inited' : spy
}
}
}, {
lazyInit : false
});

rootNode = initDom({
block : 'block',
js : { lazyInit : true }
});

spy.should.have.not.been.called;
});

describe('on DOM events', function() {
beforeEach(function() {
spy = sinon.spy();
Expand Down

0 comments on commit bc3b130

Please sign in to comment.