Skip to content

Svelte 5: hydration doesn't repair changing attributes from server to client (even in legacy mode) #14350

@paoloricciuti

Description

@paoloricciuti

Describe the bug

Something like this

<script lang="ts">
	import {browser} from "$app/environment";
</script>

<div title={browser ? "client": "server"}>div</div>

should output

<div title="client">div</div>

after hydration (at least in legacy mode) but it doesn't because the attribute is inlined and the div is not marked as dynamic.

Reproduction

repl

  1. open the main page
  2. check the html

Logs

No response

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) 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.2.3 => 5.2.3

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions