apparently we no longer need the merging logic? we can simplify and fix stuff by removing it

pull/15844/head
Rich Harris 2 months ago
parent f6358d53c9
commit 11f2c4868a

@ -160,47 +160,9 @@ export class Batch {
this.#process_root(root);
}
// if we didn't start any new async work, and no async work
// is outstanding from a previous flush, commit
if (this.#async_effects.length === 0 && this.#pending === 0) {
var merged = false;
// if there are older batches with overlapping
// state, we can't commit this batch. instead,
// we merge it into the older batches
for (const batch of batches) {
if (batch === this) break;
for (const [source] of batch.#current) {
if (this.#current.has(source)) {
merged = true;
for (const [source, value] of this.#current) {
batch.#current.set(source, value);
}
for (const e of this.#render_effects) {
set_signal_status(e, CLEAN);
batch.#render_effects.push(e);
}
for (const e of this.#effects) {
set_signal_status(e, CLEAN);
batch.#effects.push(e);
}
for (const e of this.skipped_effects) {
batch.skipped_effects.add(e);
}
for (const fn of this.#callbacks) {
batch.#callbacks.add(fn);
}
break;
}
}
}
if (!merged) {
var render_effects = this.#render_effects;
var effects = this.#effects;
@ -213,8 +175,8 @@ export class Batch {
flush_queued_effects(effects);
this.#deferred?.resolve();
}
} else {
// otherwise mark effects clean so they get scheduled on the next run
for (const e of this.#render_effects) set_signal_status(e, CLEAN);
for (const e of this.#effects) set_signal_status(e, CLEAN);
}

@ -0,0 +1,32 @@
import { tick } from 'svelte';
import { test } from '../../test';
export default test({
async test({ assert, target }) {
await tick();
const [increment] = target.querySelectorAll('button');
assert.htmlEqual(
target.innerHTML,
`
<button>increment</button>
<p>0</p>
`
);
increment.click();
await tick();
increment.click();
await tick();
assert.htmlEqual(
target.innerHTML,
`
<button>increment</button>
<p>2</p>
`
);
}
});

@ -0,0 +1,19 @@
<script>
let count = $state(0);
</script>
<button onclick={() => count += 1}>
increment
</button>
<svelte:boundary>
{#if count % 2}
<p>{await new Promise(() => {})}</p>
{:else}
<p>{await count}</p>
{/if}
{#snippet pending()}
<p>loading...</p>
{/snippet}
</svelte:boundary>
Loading…
Cancel
Save