-
Notifications
You must be signed in to change notification settings - Fork 96
Closed
Description
Bug case
const Mixin = bemDom.declMixin({ myProp : 'test' });
Block = bemDom.declBlock('block', [Mixin]);
Block.prototype.findChildBlock // undefinedbut
const Mixin = bemDom.declMixin({ myProp : 'test' });
Block = bemDom.declBlock('block', [bemDom.Block, Mixin]);
Block.prototype.findChildBlock // functionAfter add code (This is the draft version of the solution. It remains to do right now.)
/**
* Declares DOM-based block and creates block class
* @param {String|Function} blockName Block name or block class
* @param {Function|Array[Function]} [base] base block + mixes
* @param {Object} [props] Methods
* @param {Object} [staticProps] Static methods
* @returns {Function} Block class
*/
declBlock : function(blockName, base, props, staticProps) {
if(!base || (typeof base === 'object' && !Array.isArray(base))) {
staticProps = props;
props = base;
base = typeof blockName === 'string'?
entities[blockName] || Block :
blockName;
}
// added code start
base || (base = entities[blockName] || Block);
Array.isArray(base) || (base = [base]);
if(!base[0].__bemEntity) {
base = base.slice();
base.unshift(entities[blockName] || Block);
}
// added code end
return bem.declBlock(blockName, base, props, staticProps);
},Block = bemDom.declBlock('block', [Mixin]);
Block.prototype.findChildBlock // functionP.S.
A problem can also be with elements
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels