mirror of https://github.com/sveltejs/svelte
commit
0a5e7f1b62
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: reset context after waiting on blockers of `@const` expressions
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: keep flushing new eager effects
|
||||
@ -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}
|
||||
@ -0,0 +1,35 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
await tick();
|
||||
const [increment, shift] = target.querySelectorAll('button');
|
||||
|
||||
increment.click();
|
||||
await tick();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>increment</button>
|
||||
<button>shift</button>
|
||||
1
|
||||
<p>pending: 1</p>
|
||||
<p>loading...</p>
|
||||
`
|
||||
);
|
||||
|
||||
shift.click();
|
||||
await tick();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>increment</button>
|
||||
<button>shift</button>
|
||||
1
|
||||
<p>pending: 0</p>
|
||||
<p>1</p>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,27 @@
|
||||
<script>
|
||||
let value = $state(0);
|
||||
let queued = [];
|
||||
|
||||
function delayed(v) {
|
||||
if (!v) return v;
|
||||
return new Promise((resolve) => {
|
||||
queued.push(() => resolve(v));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<button onclick={() => value++}>increment</button>
|
||||
<button onclick={() => queued.shift()?.()}>shift</button>
|
||||
|
||||
{$state.eager(value)}
|
||||
|
||||
{#if 1}
|
||||
<p>pending: {$effect.pending()}</p>
|
||||
|
||||
{@const tmp = await delayed(value)}
|
||||
{#if $effect.pending() > 0}
|
||||
<p>loading...</p>
|
||||
{:else}
|
||||
<p>{tmp}</p>
|
||||
{/if}
|
||||
{/if}
|
||||
Loading…
Reference in new issue