mirror of https://github.com/sveltejs/svelte
fix: properly hydrate already-resolved async blocks (alternative) (#17641)
This is basically #17611, minus #17640, plus #17639. We need to add the $.next() call after render tags as well as components; rather than duplicating the logic, we can use is_standalone to determine when this is necessary (since this is what prevents $.append(...) from being used). Fixes #17261 Fixes #17608 --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>pull/17644/head
parent
f5304ec8c9
commit
bc44975869
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"svelte": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: properly hydrate already-resolved async blocks
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
<script>
|
||||||
|
let { children } = $props()
|
||||||
|
</script>
|
||||||
|
<div>{@render children?.()}</div>
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
<script>
|
||||||
|
let { children } = $props()
|
||||||
|
</script>
|
||||||
|
<div>{@render children?.()}</div>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<script lang='ts'>
|
||||||
|
import type { Attachment } from 'svelte/attachments'
|
||||||
|
|
||||||
|
export function action(): Attachment<HTMLElement> {
|
||||||
|
return ()=>{}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
import { tick } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
mode: ['hydrate'],
|
||||||
|
async test({ assert, target }) {
|
||||||
|
await tick();
|
||||||
|
assert.htmlEqual(target.innerHTML, '<div><div>foo</div></div>');
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
<script>
|
||||||
|
import Outer from './Outer.svelte'
|
||||||
|
import Inner from './Inner.svelte'
|
||||||
|
import Trigger from './Trigger.svelte'
|
||||||
|
|
||||||
|
const data = $derived(await Promise.resolve(['a', 'b']))
|
||||||
|
let trigger = $state()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Outer>
|
||||||
|
<Inner {@attach trigger?.action}>
|
||||||
|
foo
|
||||||
|
</Inner>
|
||||||
|
</Outer>
|
||||||
|
|
||||||
|
<Trigger bind:this={trigger} />
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
let { message, another } = $props()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>{message}</p>
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
import { tick } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
mode: ['hydrate'],
|
||||||
|
|
||||||
|
ssrHtml: `<p>item 1</p><p>item 2</p><p>item 3</p>`,
|
||||||
|
html: `<p>item 1</p><p>item 2</p><p>item 3</p>`,
|
||||||
|
|
||||||
|
async test({ assert, target }) {
|
||||||
|
await tick();
|
||||||
|
assert.htmlEqual(target.innerHTML, '<p>item 1</p><p>item 2</p><p>item 3</p>');
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
<script>
|
||||||
|
import Component from './Component.svelte'
|
||||||
|
|
||||||
|
const messages = await Promise.resolve(["item 1", "item 2", "item 3"])
|
||||||
|
const another = { test: 'test' }
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each messages as message}
|
||||||
|
<Component {message} {another} />
|
||||||
|
{/each}
|
||||||
Loading…
Reference in new issue