Skip to content

Commit

Permalink
Svelte Render Update for Svelte 5 Compatibility
Browse files Browse the repository at this point in the history
Updating the Svelte render for compatibility with the latest Svelte 5.0 release.  [Svelte 5 introduced a breaking change](sveltejs/svelte#10516) removing `createRoot`.  Instead, `mount` should be used and properties passed should be wrapped in a `$state` rune.
  • Loading branch information
mstachowiak authored Mar 1, 2024
1 parent 075f911 commit 538fd57
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ function teardown(canvasElement: SvelteRenderer['canvasElement']) {
function createRoot(target: HTMLElement, props: any) {
if ((svelte as any).createRoot) {
// Svelte v5
return (svelte as any).createRoot(PreviewRender, {
const statefulProps = $state(props);
return (svelte as any).mount(PreviewRender, {
target,
props,
statefulProps,
});
}
// Svelte v4
Expand Down

0 comments on commit 538fd57

Please sign in to comment.