From 9ab08cc330b4fce900f59bb696c8e3a31b7f3eec Mon Sep 17 00:00:00 2001 From: Sergey Belozyorcev Date: Tue, 19 Jun 2018 04:57:37 +0300 Subject: [PATCH] Throw error on declMod with lazyInit prop --- common.blocks/i-bem-dom/i-bem-dom.js | 9 +++++++++ common.blocks/i-bem-dom/i-bem-dom.spec.js | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/common.blocks/i-bem-dom/i-bem-dom.js b/common.blocks/i-bem-dom/i-bem-dom.js index df02e7369..c1fa07e9e 100644 --- a/common.blocks/i-bem-dom/i-bem-dom.js +++ b/common.blocks/i-bem-dom/i-bem-dom.js @@ -768,6 +768,15 @@ var BemDomEntity = inherit(/** @lends BemDomEntity.prototype */{ throw Error('bemDom entities can not be created otherwise than from DOM'); }, + /** @override */ + declMod : function(mod, props, staticProps) { + if(staticProps && staticProps.lazyInit !== undef) { + throw Error('declMod with lazyInit prop not allowed. Your need use \'lazyInit\' in data-bem params'); + } + + return this.__base.apply(this, arguments); + }, + /** @override */ _processInit : function(heedInit) { /* jshint eqeqeq: false */ diff --git a/common.blocks/i-bem-dom/i-bem-dom.spec.js b/common.blocks/i-bem-dom/i-bem-dom.spec.js index 68818b1a6..1b90c4b5a 100644 --- a/common.blocks/i-bem-dom/i-bem-dom.spec.js +++ b/common.blocks/i-bem-dom/i-bem-dom.spec.js @@ -164,6 +164,16 @@ describe('i-bem-dom', function() { block2.should.be.instanceOf(Block1); elem2.should.be.instanceOf(Elem1); }); + + it('should throw error if declMod contains lazyInit static property', function() { + var Block = bemDom.declBlock('block'); + + function mod() { + Block.declMod({ modName : 'mod' }, null, { lazyInit : true }); + } + + mod.should.throw(Error, 'declMod with lazyInit prop not allowed. Your need use \'lazyInit\' in data-bem params'); + }); }); describe('getMod', function() {