Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { tick } from 'svelte';
import { test } from '../../test';

export default test({
async test({ assert, target }) {
const shift = document.querySelector('button');
shift?.click();
await tick();
shift?.click();
await tick();

assert.htmlEqual(
target.innerHTML,
`
<p>true</p>
<button>toggle</button>
<button>shift</button>
`
);

const toggle = target.querySelector('button');
toggle?.click();
await tick();

assert.htmlEqual(
target.innerHTML,
`
<p>true</p>
<button>toggle</button>
<button>shift</button>
`
);

shift?.click();
await tick();

assert.htmlEqual(
target.innerHTML,
`
<p>true</p>
<button>toggle</button>
<button>shift</button>
`
);

shift?.click();
await tick();

assert.htmlEqual(
target.innerHTML,
`
<button>toggle</button>
<button>shift</button>
`
);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<script>
let show = $state(true);
let count = $state(0);
let queue = [];

function foo() {
const {promise, resolve} = Promise.withResolvers();
const s = show;
queue.push(() => resolve(s));
return promise;
}

function bar() {
const {promise, resolve} = Promise.withResolvers();
const s = show;
queue.push(() => {
// This will create a new batch while the other batch is still in flight
count++
resolve(s);
});
return promise;
}

$effect(() => { count; });
</script>

<svelte:boundary>
{#if await foo()}
<p>{await bar()}</p>
{/if}

<button onclick={() => {
show = !show
}}>toggle</button>

{#snippet pending()}
<p>loading...</p>
{/snippet}
</svelte:boundary>

<button onclick={() => queue.shift()()}>shift</button>
Loading