Closed
Description
Describe the bug
Using {@html someVar}
in Svelte 5, I noticed that hydration does not overwrite the SSR value. For example (and this is in the reproduction repo), consider this component in a SvelteKit app:
<script>
import { browser } from "$app/environment"
const renderLocation = browser ? "In browser" : "On server"
</script>
<h1>Welcome to SvelteKit</h1>
Standard: {renderLocation}
<br />
@html: {@html renderLocation}
I would expect that after hydration, the page would say:
<h1>Welcome to SvelteKit</h1>
Standard: In browser
<br />
@html: In browser
But instead, it says:
<h1>Welcome to SvelteKit</h1>
Standard: In browser
<br />
@html: On server
Reproduction
https://github.com/happycollision/svelte-hydration-issue
- Clone the repo.
- There are two folders, svelte5 and svelte4. In both, you should
pnpm i
. - Do
npm run dev
in one, check the output of the root route. - Do the same in the other and see that it is different.
In the svelte 4 version, you'll see this:
In the svelte 5 version, you'll see this:
NOTE: There are no runes in use in the Svelte 5 version.
Logs
No response
System Info (svelte4)
System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M1 Pro
Memory: 1.93 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.10.0 - ~/.asdf/installs/nodejs/20.10.0/bin/node
npm: 10.2.3 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 9.0.6 - ~/.asdf/installs/nodejs/20.10.0/.npm/bin/pnpm
bun: 1.0.3 - ~/.bun/bin/bun
Browsers:
Brave Browser: 126.1.67.123
Safari: 17.4.1
npmPackages:
svelte: ^4.2.7 => 4.2.18
System Info (svelte5)
System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M1 Pro
Memory: 1.11 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.10.0 - ~/.asdf/installs/nodejs/20.10.0/bin/node
npm: 10.2.3 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 9.0.6 - ~/.asdf/installs/nodejs/20.10.0/.npm/bin/pnpm
bun: 1.0.3 - ~/.bun/bin/bun
Browsers:
Brave Browser: 126.1.67.123
Safari: 17.4.1
npmPackages:
svelte: ^5.0.0-next.1 => 5.0.0-next.175
Severity
blocking an upgrade