Skip to content

<svelte:element> hydration is broken in with SvelteKitΒ #14272

@bleucitron

Description

@bleucitron

Describe the bug

I'm not sure if this should be in Svelte or Kit repo, but since it appeared with Svelte 5, i'm posting it here.

<svelte:element> is not properly hydrated when using SSR with SvelteKit.

With the following code, the page should render a button once hydrated:

  • it does with Svelte 4
  • it does not with Svelte 5
<script>
	import { browser } from '$app/environment';
	$: t = browser ? 'button' : 'div';
	$: console.log('T', t);
</script>

<svelte:element this={t}>{t}</svelte:element>

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-qcekrk?file=package.json,src%2Froutes%2F%2Bpage.svelte

Logs

No response

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (2) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    svelte: ^5.1.15 => 5.1.15

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions