bem-cn icon indicating copy to clipboard operation
bem-cn copied to clipboard

Can't add modifier to element

Open arjun-ltse opened this issue 4 years ago • 1 comments

If I create an element on a block:

const myBlock = block('my-block') // my-block
const myBlockElement = myBlock('my-element') // my-block__my-element

It seems that element is "not a function" when I try:

const myBlockElementWithModifier = myBlockElement({ modifier: true }) // should be my-block__my-element--modifier

I get Uncaught TypeError: blockElement is not a function

It seems this worked fine in previous versions of bem-cn. Did something major change?

arjun-ltse avatar Mar 13 '20 22:03 arjun-ltse

@arjun-ltse, the API for the modifiers has been changed. So, if you want to apply a modifier to the element, you should do it when you build the element:

const myBlockElementWithModifier = myBlock('my-element', { modifier: true })

mistakster avatar Apr 02 '20 04:04 mistakster