Skip to content

Commit

Permalink
Fix Svelte 4 slot rendering issues (#1763)
Browse files Browse the repository at this point in the history
* Moved svelte:component into key block

* Formatting

---------

Co-authored-by: Jonathan Reinink <jonathan@reinink.ca>
  • Loading branch information
dunhamjared and reinink authored Apr 16, 2024
1 parent 5e9c52a commit 645d710
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions packages/svelte/src/Render.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@
export let component
export let props = {}
export let children = []
let prevComponent
let key
$: {
if (prevComponent !== component) {
key = Date.now()
prevComponent = component
}
}
</script>

{#if $store.component}
<svelte:component this={component} {...props}>
{#each children as child, index (component && component.length === index ? $store.key : null)}
<svelte:self {...child} />
{/each}
</svelte:component>
{#key key}
<svelte:component this={component} {...props}>
{#each children as child, index (component && component.length === index ? $store.key : null)}
<svelte:self {...child} />
{/each}
</svelte:component>
{/key}
{/if}

0 comments on commit 645d710

Please sign in to comment.