Skip to content

Commit 9b4ae9e

Browse files
shlenskycursoragent
authored andcommitted
fix(core): warn when composeSimple receives modifiers from different blocks
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent cd60067 commit 9b4ae9e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/core/core.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,19 @@ export type Composition<T> = <U extends ComponentType<any>>(
169169

170170
function composeSimple(mods: any[]) {
171171
const { __blockName } = mods[0]
172+
173+
for (const mod of mods) {
174+
if (mod.__blockName !== __blockName) {
175+
console.error(
176+
new Error(
177+
'[bem-react] composeSimple: all modifiers must belong to the same block. '
178+
+ `Expected "${__blockName}", got "${mod.__blockName}" for modifier "${mod.__mod}". `
179+
+ 'The modifier will be applied incorrectly.',
180+
),
181+
)
182+
}
183+
}
184+
172185
const allMods: Record<string, (string | boolean)[]> = {}
173186
const allModsPassProps: Record<string, boolean[]> = {}
174187

0 commit comments

Comments
 (0)