Repository: sveltejs/svelte (JavaScript)

Issue:
Svelte 5: An empty string in `@html` causes a warning during hydration.
### Describe the bug

`<div>{@html ''}</div>`

results in this:

<img width="627" alt="image" src="https://github.com/user-attachments/assets/59749e88-01c3-46a8-98b7-b4686671a8e5">



### Reproduction

[Link](https://www.sveltelab.dev/?files=.%2Fsrc%2Froutes%2F%2Bpage.svelte#code=N4IgdA5glgLlEDsD2AnApiAXKAZlANhtiAMZIIxoUDOWoA1lAgCZYjUBua%2Bl%2BAhgCMAtAFcoADj4gANCAEicONCiwBtACwA2aZvHTxAZmkBOAKz6jARkvbrl6dfUOADPcvOH7z2%2Bcf39sxdjbxc-SwB2Fz1-T3MvdUjjaIiXOOdo3xdpBOzbSzjLDJ9k21dstMj3AtLsyssAJhNE4PdEyucrMvjSty9rDNyXXrC9LWzGrwMjMZjrEcHZ%2Bo9jdpaGqKGs-tTPHsHjNeGXCec06dK88xmbHfcWrvzdpqDPRvUrk88M6s2xg5C5sdbh0FjdrFc8qU0vdej8Vi9rG8Pi4ALoAXwxsjAAAd0DA4MoUCQ6CA8IQSWQKFQYLRiIwWGxONxeIJRBIpLJ5IplGoGp0TNIDE5rHU0vZxE54UlYoKnKY9AYJmDLMKUjF1MLlrKZVVPH4Qe4ivpenVenshdJ5YKlXlVe17BqssELdZbc9dYbbn0QZpTQjnMF4RarYrtYC7HrNhbHV5naqlZqCmFtOJ2mlky4nMGFW9gupRqNNQKXetPSKXJ0kzLs9aTPYSwnNq6nh6Hk53q8NuX3JXIx3wV8m%2BkW2ULcZpkW4wDCk2VZ5E6FZ%2BYa6HjG56kZQy7nCc0kaByvGtG3pdB7Nh82YtGs0fVb0bV6jge5TmHBvaw33XOB7M54ew482zniUUY3m%2By4TPU5jjlsUGohiaKyNifAkPQfAQGgYAAFbUOQJJkkQoCUpQNAkvSrCYOwXA8NwrJiJIMhyAoSgqJgqh8k6AHLKsoGWq%2BY56PCP6nCYU4xlqJb7t%2BgEiRGgL-tGozaPmgzqGJk4AY2Hoz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JGlIycEq0dElhcI0EToyQ34HoraaZEIEhK4IY%2BIsFOWA8E4G4v8E4BlEuChG2ZkoaL8GtdIj4mKF9G4D44Y84zpPGGYSlXgkYtxGaNpKU0UlE41BwhVJ1BueVfUJsDPKWEw4tXjfOaKZQ0kvwgpFw4EIwdUgdWQBTSgcg8gSg6g4gIjZ5GdTTEABgijJguiX5VdHeXkEKTg%2Bbbggwz4oCAhQmQAuwyCCDIQwoj8bbcQgZcMmwwk9okmRaK8NQrYf0nIwqIU4MihFOFVXKXyJwvaVwkETNaMoEl4UQ0Mn4DM%2B1LMzUsILkk4%2BOHwA0h4o0nyIcVw70aNP0XY8s6YdPUIlKRWNw4ssfV8CLKpRMmUlM%2B2IGAIfkBuBwi0hCNEIAA)

### Logs

_No response_

### System Info

```shell
Svelte 5.0.0-next.230.
```


### Severity

annoyance


Discussion:
I will add that I did not find any breakage in my code, only a warning in the console.



Patch:
diff --git a/.changeset/shiny-wombats-argue.md b/.changeset/shiny-wombats-argue.md
new file mode 100644
index 000000000000..b35f1cf304b0
--- /dev/null
+++ b/.changeset/shiny-wombats-argue.md
@@ -0,0 +1,5 @@
+---
+'svelte': patch
+---
+
+fix: correctly hydrate empty raw blocks
diff --git a/packages/svelte/src/internal/client/dom/blocks/html.js b/packages/svelte/src/internal/client/dom/blocks/html.js
index cdfa1baa71e6..1240352ea0dd 100644
--- a/packages/svelte/src/internal/client/dom/blocks/html.js
+++ b/packages/svelte/src/internal/client/dom/blocks/html.js
@@ -46,15 +46,20 @@ export function html(node, get_value, svg, mathml, skip_warning) {
 
 	var value = '';
 
-	/** @type {Effect | null} */
+	/** @type {Effect | undefined} */
 	var effect;
 
 	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);
-			effect = null;
+			effect = undefined;
 		}
 
 		if (value === '') return;


Test patch:
diff --git a/packages/svelte/tests/hydration/samples/raw-empty/_config.js b/packages/svelte/tests/hydration/samples/raw-empty/_config.js
new file mode 100644
index 000000000000..5f4d5bebb1b3
--- /dev/null
+++ b/packages/svelte/tests/hydration/samples/raw-empty/_config.js
@@ -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>');
+	}
+});
diff --git a/packages/svelte/tests/hydration/samples/raw-empty/main.svelte b/packages/svelte/tests/hydration/samples/raw-empty/main.svelte
new file mode 100644
index 000000000000..c7ff3d05c986
--- /dev/null
+++ b/packages/svelte/tests/hydration/samples/raw-empty/main.svelte
@@ -0,0 +1,1 @@
+<div>{@html ''}</div>