diff --git a/.changeset/giant-jars-applaud.md b/.changeset/giant-jars-applaud.md new file mode 100644 index 000000000000..b338b3a822bb --- /dev/null +++ b/.changeset/giant-jars-applaud.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure hydration walks all nodes diff --git a/packages/svelte/src/internal/client/dom/operations.js b/packages/svelte/src/internal/client/dom/operations.js index 5d16632bbd7c..c6130c4332a3 100644 --- a/packages/svelte/src/internal/client/dom/operations.js +++ b/packages/svelte/src/internal/client/dom/operations.js @@ -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; @@ -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`) @@ -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); diff --git a/packages/svelte/src/internal/client/dom/template.js b/packages/svelte/src/internal/client/dom/template.js index 3ef0b181b7b5..60e6995d40cf 100644 --- a/packages/svelte/src/internal/client/dom/template.js +++ b/packages/svelte/src/internal/client/dom/template.js @@ -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();