Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svelte 5: <noscript> breaks hydration #9952

Closed
tombl opened this issue Dec 18, 2023 · 0 comments
Closed

Svelte 5: <noscript> breaks hydration #9952

tombl opened this issue Dec 18, 2023 · 0 comments

Comments

@tombl
Copy link
Contributor

tombl commented Dec 18, 2023

Describe the bug

When generating the client-side code, <noscript> elements are completely stripped out of the template.

This means that the server generates the elements, but the client acts as if they were never there. At best, this throws a hydration error, and at worst the wrong nodes are updated.

I've got a PR that solves this by turning <noscript> into a comment node in the client template.

Reproduction

REPL

<script>
  import { onMount } from "svelte";
  let count = 0;
  onMount(() => count++);
</script>
<noscript>JavaScript is required for this site.</noscript>
<h1>Hello!</h1>
<p>Count: {count}</p>

Results in <h1>Count: 1</h1> <p>Count: 0</p> hydrated to the DOM.
In Svelte 4 this renders fine.

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.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.10.5 - /usr/local/bin/pnpm
  npmPackages:
    svelte: 5.0.0-next.26 => 5.0.0-next.26

Severity

blocking an upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant