Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Svelte 4 slot rendering issues #1763

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Moved svelte:component into key block
dunhamjared authored and reinink committed Apr 16, 2024
commit 69662e075981003dcf494d2981d434711327de61
21 changes: 16 additions & 5 deletions packages/svelte/src/Render.svelte
Original file line number Diff line number Diff line change
@@ -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}