Skip to content

Commit ef78b1e

Browse files
committed
fix: add missing hydration mismatch call-site
1 parent 3515776 commit ef78b1e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/svelte/src/internal/client/dom/hydration.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/** @import { TemplateNode } from '#client' */
22

3-
import { HYDRATION_END, HYDRATION_START, HYDRATION_START_ELSE } from '../../../constants.js';
3+
import {
4+
HYDRATION_END,
5+
HYDRATION_ERROR,
6+
HYDRATION_START,
7+
HYDRATION_START_ELSE
8+
} from '../../../constants.js';
9+
import * as w from '../warnings.js';
410

511
/**
612
* 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) {
2834
}
2935

3036
export function hydrate_next() {
37+
if (hydrate_node === null) {
38+
w.hydration_mismatch();
39+
throw HYDRATION_ERROR;
40+
}
3141
return (hydrate_node = /** @type {TemplateNode} */ (hydrate_node.nextSibling));
3242
}
3343

playgrounds/demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</head>
99
<body>
1010
<noscript>You need to enable JavaScript to run this app.</noscript>
11-
<div id="root"><!--ssr-body--></div>
11+
<div id="root"><!--[-->Hello<!--]--></div>
1212

1313
<script type="module">
1414
import { mount, hydrate, unmount } from 'svelte';

0 commit comments

Comments
 (0)