Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return function WithBemMod(
WrappedComponent: ComponentType,
) {
// Use cache to prevent create new component when props are changed.
let ModifiedComponent: ComponentType
let modifierClassName: string
entity = entity || cn(blockName)
entityClassName = entityClassName || entity()
function BemMod(props: T & K) {
modNames = modNames || Object.keys(mod)
// TODO: For performance can rewrite `every` to `for (;;)`.
const isModifierMatched = modNames.every((key: string) => {
const modValue = mod[key]
const propValue = (props as any)[key]
return modValue === propValue || (modValue === '*' && Boolean(propValue))
})
if (isModifierMatched) {
const modifiers = modNames.reduce((acc: Dictionary, key: string) => {
if (mod[key] !== '*') acc[key] = mod[key]