Skip to content

Commit f6b6849

Browse files
committed
Fix extensions applying twice fix breaking extensions for components used by composition
1 parent baa5179 commit f6b6849

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Component.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,13 +1201,24 @@ namespace Component {
12011201
return resultBuilder
12021202

12031203
function applyExtensions (component: Component) {
1204-
if (!component || SYMBOL_EXTENSIONS_APPLIED in component)
1204+
if (!component)
1205+
return component
1206+
1207+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1208+
const editableComponent = component as any
1209+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1210+
let extensionsApplied = editableComponent[SYMBOL_EXTENSIONS_APPLIED] as unknown[] | undefined
1211+
if (extensionsApplied?.includes(realBuilder))
12051212
return component
12061213

12071214
for (const extension of extensions)
12081215
Object.assign(component, extension(component))
12091216

1210-
Object.defineProperty(component, SYMBOL_EXTENSIONS_APPLIED, { value: true })
1217+
if (!extensionsApplied)
1218+
Object.defineProperty(component, SYMBOL_EXTENSIONS_APPLIED, { value: extensionsApplied = [] })
1219+
1220+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
1221+
editableComponent[SYMBOL_EXTENSIONS_APPLIED].push(realBuilder)
12111222
return component
12121223
}
12131224

0 commit comments

Comments
 (0)