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 <rich.harris@vercel.com>
pull/12978/head
Dominic Gannaway 4 months ago committed by GitHub
parent 448f21620f
commit 5bdf71639e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: correctly hydrate empty raw blocks

@ -46,15 +46,20 @@ export function html(node, get_value, svg, mathml, skip_warning) {
var value = ''; var value = '';
/** @type {Effect | null} */ /** @type {Effect | undefined} */
var effect; var effect;
block(() => { block(() => {
if (value === (value = get_value())) return; if (value === (value = get_value())) {
if (hydrating) {
hydrate_next();
}
return;
}
if (effect) { if (effect !== undefined) {
destroy_effect(effect); destroy_effect(effect);
effect = null; effect = undefined;
} }
if (value === '') return; if (value === '') return;

@ -0,0 +1,15 @@
import { test } from '../../test';
export default test({
server_props: {
html: '<div></div>'
},
props: {
html: '<div></div>'
},
test(assert, target) {
assert.htmlEqual(target.innerHTML, '<div></div>');
}
});
Loading…
Cancel
Save