From 6432a9c52f9efb6d952ebe13f2d072106e30b4a6 Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Tue, 7 Jan 2025 13:57:30 +0200 Subject: [PATCH] Log error if no definition is passed to collection component --- .../CollectionComponent.ts | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts b/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts index 9c0cbbcbf..c5c29ea1a 100644 --- a/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts +++ b/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts @@ -14,25 +14,34 @@ import DynamicVariableListenerManager from '../DataVariableListenerManager'; export default class CollectionComponent extends Component { constructor(props: CollectionComponentDefinition, opt: ComponentOptions) { const em = opt.em; + // @ts-ignore + const cmp: CollectionComponent = super( + // @ts-ignore + { + ...props, + components: undefined, + droppable: false, + }, + opt, + ); + const collectionDefinition = props[keyCollectionDefinition]; + if (!collectionDefinition) { + em.logError('missing collection definition'); + + return cmp; + } + const parentCollectionStateMap = (props[keyCollectionsStateMap] || {}) as CollectionsStateMap; const components: Component[] = getCollectionItems(em, collectionDefinition, parentCollectionStateMap, opt); - const conditionalCmptDef = { - ...props, - type: CollectionComponentType, - droppable: false, - }; - - // @ts-ignore - const cmp: CollectionComponent = super(conditionalCmptDef, opt); if (this.hasDynamicDataSource()) { this.watchDataSource(em, collectionDefinition, parentCollectionStateMap, opt); } cmp.components(components); - return cmp as CollectionComponent; + return cmp; } static isComponent(el: HTMLElement) {