mirror of https://github.com/sveltejs/svelte
commit
203fe2e62e
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: propagate async `@const` blockers through closure references so template expressions like `{(() => host)()}` correctly wait for the awaited value
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
import { tick } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
// Tests that an IIFE referencing an `await` @const inside an {#each} block
|
||||||
|
// correctly registers the async dependency so the template waits for the
|
||||||
|
// resolved value instead of rendering with `undefined`.
|
||||||
|
export default test({
|
||||||
|
mode: ['client', 'hydrate', 'async-server'],
|
||||||
|
ssrHtml: '<p>example.com</p>',
|
||||||
|
async test({ assert, target }) {
|
||||||
|
await tick();
|
||||||
|
assert.htmlEqual(target.innerHTML, '<p>example.com</p>');
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
<script>
|
||||||
|
async function get_host() {
|
||||||
|
return 'example.com';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each { length: 1 } as nothing}
|
||||||
|
{@const host = await get_host()}
|
||||||
|
<p>{(() => host)()}</p>
|
||||||
|
{/each}
|
||||||
Loading…
Reference in new issue