mirror of https://github.com/sveltejs/svelte
fix: reset context after waiting on blockers of `@const` expressions (#18100)
Regression from #18039 - we need to have each await expression (and waiting on blockers is one) in its own entry of `(renderer.)run`. Else context is not restored correctly and if the synchronous expression afterwards requires it stuff breaks. Fixes #18098pull/18111/head
parent
273f1a85a4
commit
0ed8c282f9
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: reset context after waiting on blockers of `@const` expressions
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import { tick } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
// Tests that context is restored after await (const has to wait on a blocker), so that getContext etc work correctly
|
||||||
|
export default test({
|
||||||
|
mode: ['hydrate', 'async-server', 'client'],
|
||||||
|
async test({ assert, target }) {
|
||||||
|
await tick();
|
||||||
|
assert.htmlEqual(target.innerHTML, 'hi');
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
import { getContext } from 'svelte';
|
||||||
|
const _unused = $derived(await 1);
|
||||||
|
//This must be created after any $derived(await...)
|
||||||
|
const bar = $derived(getContext('') ?? 'hi');
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if true}
|
||||||
|
{@const foo = bar}
|
||||||
|
{foo}
|
||||||
|
{/if}
|
||||||
Loading…
Reference in new issue