Skip to content

Commit 5bdf716

Browse files
trueadmRich-Harris
andauthored
fix: correctly hydrate empty raw blocks (#12979)
* fix: correctly hydrate empty raw blocks * lint * Update packages/svelte/src/internal/client/dom/blocks/html.js --------- Co-authored-by: Rich Harris <[email protected]>
1 parent 448f216 commit 5bdf716

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

.changeset/shiny-wombats-argue.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: correctly hydrate empty raw blocks

packages/svelte/src/internal/client/dom/blocks/html.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,20 @@ export function html(node, get_value, svg, mathml, skip_warning) {
4646

4747
var value = '';
4848

49-
/** @type {Effect | null} */
49+
/** @type {Effect | undefined} */
5050
var effect;
5151

5252
block(() => {
53-
if (value === (value = get_value())) return;
53+
if (value === (value = get_value())) {
54+
if (hydrating) {
55+
hydrate_next();
56+
}
57+
return;
58+
}
5459

55-
if (effect) {
60+
if (effect !== undefined) {
5661
destroy_effect(effect);
57-
effect = null;
62+
effect = undefined;
5863
}
5964

6065
if (value === '') return;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
server_props: {
5+
html: '<div></div>'
6+
},
7+
8+
props: {
9+
html: '<div></div>'
10+
},
11+
12+
test(assert, target) {
13+
assert.htmlEqual(target.innerHTML, '<div></div>');
14+
}
15+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div>{@html ''}</div>

0 commit comments

Comments
 (0)