mirror of https://github.com/sveltejs/svelte
fix: don't override new current_batch (#18170)
This is a regression from #18117 - we moved `this.#commit()` higher up but that means that `current_batch` could be nulled out / overridden through `batch.activate/deactivate` / blocker runs inside `#commit()`. Therefore restore the previous value afterwards. No changest because #18117 is not released yet. Fixes the other part of the failing SvelteKit `query.live` test. --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/18184/head
parent
d4c5a91735
commit
5e054574db
@ -0,0 +1,19 @@
|
|||||||
|
import { tick } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
// Tests that batch.#commit() does not null out a potentially new current_batch
|
||||||
|
export default test({
|
||||||
|
skip_initial_flushSync: true, // test that the initial batch is flushed without an explicit flushSync() call
|
||||||
|
async test({ assert, target }) {
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
const [button] = target.querySelectorAll('button');
|
||||||
|
const [updates] = target.querySelectorAll('p');
|
||||||
|
|
||||||
|
assert.htmlEqual(updates.innerHTML, 'false');
|
||||||
|
|
||||||
|
button.click();
|
||||||
|
await tick();
|
||||||
|
assert.htmlEqual(updates.innerHTML, 'true');
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
<script>
|
||||||
|
let count = $state(-1);
|
||||||
|
let payload = $state(false);
|
||||||
|
let updated = $state(false);
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (payload) {
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
count = 0;
|
||||||
|
queueMicrotask(() => {
|
||||||
|
payload = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={update}>update</button>
|
||||||
|
|
||||||
|
<p>{updated}</p>
|
||||||
|
|
||||||
|
<svelte:boundary>
|
||||||
|
{await new Promise(() => {})}
|
||||||
|
|
||||||
|
{#snippet pending()}
|
||||||
|
<p>pending</p>
|
||||||
|
{/snippet}
|
||||||
|
</svelte:boundary>
|
||||||
Loading…
Reference in new issue