From 5a072198362364291e0d5c9a042feeace67b0cc9 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Thu, 25 Jul 2024 16:30:52 +0100 Subject: [PATCH] fix: add missing hydration mismatch call-site (#12604) * fix: add missing hydration mismatch call-site * add changeset * Update playgrounds/demo/index.html Co-authored-by: Conduitry --------- Co-authored-by: Conduitry --- .changeset/hip-stingrays-teach.md | 5 +++++ packages/svelte/src/internal/client/dom/hydration.js | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .changeset/hip-stingrays-teach.md diff --git a/.changeset/hip-stingrays-teach.md b/.changeset/hip-stingrays-teach.md new file mode 100644 index 0000000000..4f82007fbb --- /dev/null +++ b/.changeset/hip-stingrays-teach.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: add missing hydration mismatch call-site diff --git a/packages/svelte/src/internal/client/dom/hydration.js b/packages/svelte/src/internal/client/dom/hydration.js index 8b03fe7f9e..5f0880a676 100644 --- a/packages/svelte/src/internal/client/dom/hydration.js +++ b/packages/svelte/src/internal/client/dom/hydration.js @@ -1,6 +1,12 @@ /** @import { TemplateNode } from '#client' */ -import { HYDRATION_END, HYDRATION_START, HYDRATION_START_ELSE } from '../../../constants.js'; +import { + HYDRATION_END, + HYDRATION_ERROR, + HYDRATION_START, + HYDRATION_START_ELSE +} from '../../../constants.js'; +import * as w from '../warnings.js'; /** * Use this variable to guard everything related to hydration code so it can be treeshaken out @@ -28,6 +34,10 @@ export function set_hydrate_node(node) { } export function hydrate_next() { + if (hydrate_node === null) { + w.hydration_mismatch(); + throw HYDRATION_ERROR; + } return (hydrate_node = /** @type {TemplateNode} */ (hydrate_node.nextSibling)); }