1
0
Fork 0
mirror of synced 2024-06-29 19:41:03 +12:00

Stop component crashing if children don't exist

This commit is contained in:
Andrew Kingston 2021-01-22 11:08:42 +00:00
parent 3104df6224
commit 6393c0798e

View file

@ -21,7 +21,7 @@
// Extract component definition info
$: constructor = getComponentConstructor(definition._component)
$: children = definition._children
$: children = definition._children || []
$: id = definition._id
$: enrichComponentProps(definition, $dataContext, $bindingStore)
$: updateProps(enrichedProps)
@ -33,7 +33,11 @@
$builderStore.previewType === "layout" || screenslotContext
// Update component context
$: componentStore.set({ id, children: children.length, styles: { ...styles, id, allowSelection } })
$: componentStore.set({
id,
children: children.length,
styles: { ...styles, id, allowSelection },
})
// Updates the component props.
// Most props are deeply compared so that svelte will only trigger reactive
@ -78,7 +82,7 @@
{#if constructor && componentProps}
<svelte:component this={constructor} {...componentProps}>
{#if children && children.length}
{#if children.length}
{#each children as child (getChildKey(child._id))}
<svelte:self definition={child} />
{/each}