Skip to content

fix: ensure hydration walks all nodes #12448

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

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/giant-jars-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ensure hydration walks all nodes
6 changes: 3 additions & 3 deletions packages/svelte/src/internal/client/dom/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export function empty() {
}

/**
* Don't mark this as side-effect-free, hydration needs to walk all nodes
* @template {Node} N
* @param {N} node
* @returns {Node | null}
*/
/*#__NO_SIDE_EFFECTS__*/
export function child(node) {
if (!hydrating) {
return node.firstChild;
Expand All @@ -73,11 +73,11 @@ export function child(node) {
}

/**
* Don't mark this as side-effect-free, hydration needs to walk all nodes
* @param {DocumentFragment | TemplateNode[]} fragment
* @param {boolean} is_text
* @returns {Node | null}
*/
/*#__NO_SIDE_EFFECTS__*/
export function first_child(fragment, is_text) {
if (!hydrating) {
// when not hydrating, `fragment` is a `DocumentFragment` (the result of calling `open_frag`)
Expand All @@ -103,12 +103,12 @@ export function first_child(fragment, is_text) {
}

/**
* Don't mark this as side-effect-free, hydration needs to walk all nodes
* @template {Node} N
* @param {N} node
* @param {boolean} is_text
* @returns {Node | null}
*/
/*#__NO_SIDE_EFFECTS__*/
export function sibling(node, is_text = false) {
if (!hydrating) {
return /** @type {TemplateNode} */ (node.nextSibling);
Expand Down
4 changes: 3 additions & 1 deletion packages/svelte/src/internal/client/dom/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ function run_scripts(node) {
}
}

/*#__NO_SIDE_EFFECTS__*/
/**
* Don't mark this as side-effect-free, hydration needs to walk all nodes
*/
export function text() {
if (!hydrating) {
var t = empty();
Expand Down
Loading