mirror of https://github.com/sveltejs/svelte
fix: prevent async render tag hydration mismatches (#17652)
If the render tag is wrapped in `$.async`, that `$.async` call already contains surrounding markers, so we must not add our own to avoid hydration mismatches. Related to #17641, fixes #17225pull/16867/merge
parent
d047bc6e2a
commit
0a404c9863
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: prevent async render tag hydration mismatches
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import { tick } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
mode: ['hydrate'],
|
||||||
|
|
||||||
|
async test({ assert, target }) {
|
||||||
|
await tick();
|
||||||
|
assert.htmlEqual(target.innerHTML, `Count: 1 Double: 2`);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
let count = $state(1);
|
||||||
|
async function getDouble(count: number) {
|
||||||
|
return count * 2;
|
||||||
|
}
|
||||||
|
const double = $derived(await getDouble(count));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
Count: {count}
|
||||||
|
|
||||||
|
{#snippet ssr(num: number)}
|
||||||
|
{num}
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
Double: {@render ssr(double)}
|
||||||
Loading…
Reference in new issue