mirror of https://github.com/sveltejs/svelte
parent
523c85bd3d
commit
6a7e033be1
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: coordinate mount of snippets with await expressions
|
||||
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
let { children, push } = $props();
|
||||
let message = await push('hello from child');
|
||||
</script>
|
||||
|
||||
<p>message: {message}</p>
|
||||
{@render children()}
|
||||
@ -0,0 +1,25 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
const [shift] = target.querySelectorAll('button');
|
||||
|
||||
shift.click();
|
||||
await tick();
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `<button>shift</button><p>loading...</p>`);
|
||||
|
||||
shift.click();
|
||||
await tick();
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>shift</button>
|
||||
<p>message: hello from child</p>
|
||||
<p>hello from parent</p>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,21 @@
|
||||
<script>
|
||||
import Child from './Child.svelte';
|
||||
const resolvers = [];
|
||||
function push(value) {
|
||||
const { promise, resolve } = Promise.withResolvers();
|
||||
resolvers.push(() => resolve(value));
|
||||
return promise;
|
||||
}
|
||||
</script>
|
||||
|
||||
<button onclick={() => resolvers.shift()?.()}>shift</button>
|
||||
|
||||
<svelte:boundary>
|
||||
<Child {push}>
|
||||
<p>{await push('hello from parent')}</p>
|
||||
</Child>
|
||||
|
||||
{#snippet pending()}
|
||||
<p>loading...</p>
|
||||
{/snippet}
|
||||
</svelte:boundary>
|
||||
Loading…
Reference in new issue