sveltejs / svelte

web development for the rest of us
https://svelte.dev
MIT License
80.02k stars 4.26k forks source link

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

Open paoloricciuti opened 2 hours ago

paoloricciuti commented 2 hours ago

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

Conduitry commented 2 hours ago

This feels adjacent to #13517 / #14272. IMO we shouldn't try to handle this, and we should document this as a breaking change.

paoloricciuti commented 2 hours ago

This feels adjacent to #13517 / #14272. IMO we shouldn't try to handle this, and we should document this as a breaking change.

This worked in 5.1 in legacy mode so we can't really add a breaking