Skip to content

Hydration crashes when using app via Google Translate (or many other HTML whitespace manipulations) #16242

@janvogt

Description

@janvogt

Describe the bug

When visiting a non trivial Svelte 5 page using Google Translate the correct content flashes before turning into a blank page.

The reason is, that Google Translate inserts whitespace into the DOM. This breaks critical assumptions within the hydration logic. In my case a component tried to access $.child(x) while hydration_node.nodeType === TEXT_NODE. Which lead to Uncaught (in promise) DOMException: Node.appendChild: Cannot add children to a Text.

This issue is closely related to #15819, but was not fixed by PR #15851.

Reproduction

I will send a pull request with a failing test and a proposed solution.

Logs

System Info

System:
    OS: Linux 6.6 cpe:/o:nixos:nixos:24.11 24.11 (Vicuna)
    CPU: (16) arm64 Neoverse-N1
    Memory: 20.70 GB / 30.53 GB
    Container: Yes
    Shell: 3.7.1 - /run/current-system/sw/bin/fish
  Binaries:
    Node: 20.19.1 - /nix/store/k770bck0i7d6c8ffc9gb4v2rxj3dvfbs-nodejs-20.19.1/bin/node
    npm: 10.8.2 - /nix/store/k770bck0i7d6c8ffc9gb4v2rxj3dvfbs-nodejs-20.19.1/bin/npm
    pnpm: 9.15.9 - /nix/store/9ah9ki946jl3jx6lcmwvzxcx3irgji29-pnpm-9.15.9/bin/pnpm
  npmPackages:
    svelte: workspace:^ => 5.34.8

Severity

blocking all usage of svelte

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions