mirror of https://github.com/sveltejs/svelte
When deferring effects we didn't unmark the deriveds that lead to those effects. This means that they might not be reached in subsequent runs of `mark_reactions`. Fixes https://github.com/sveltejs/svelte/issues/17118#issuecomment-3521488865pull/17147/head
parent
e238e6611e
commit
8f7e8b936e
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: ensure deferred effects can be rescheduled later on
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
import { tick } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
async test({ assert, target, logs }) {
|
||||||
|
assert.deepEqual(logs, [0]);
|
||||||
|
|
||||||
|
const [fork1, fork2, commit] = target.querySelectorAll('button');
|
||||||
|
|
||||||
|
fork1.click();
|
||||||
|
await tick();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>fork 1</button>
|
||||||
|
<button>fork 2</button>
|
||||||
|
<button>commit</button>
|
||||||
|
<p>0</p>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
assert.deepEqual(logs, [0]);
|
||||||
|
|
||||||
|
fork2.click();
|
||||||
|
await tick();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>fork 1</button>
|
||||||
|
<button>fork 2</button>
|
||||||
|
<button>commit</button>
|
||||||
|
<p>0</p>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
assert.deepEqual(logs, [0]);
|
||||||
|
|
||||||
|
commit.click();
|
||||||
|
await tick();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>fork 1</button>
|
||||||
|
<button>fork 2</button>
|
||||||
|
<button>commit</button>
|
||||||
|
<p>1</p>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
assert.deepEqual(logs, [0, 1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
<script>
|
||||||
|
import { fork } from "svelte";
|
||||||
|
|
||||||
|
let state = $state(0);
|
||||||
|
|
||||||
|
let count = $derived(state);
|
||||||
|
|
||||||
|
$effect.pre(() => {
|
||||||
|
console.log(count);
|
||||||
|
});
|
||||||
|
|
||||||
|
let forked;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={()=>{
|
||||||
|
forked?.discard?.();
|
||||||
|
forked = fork(()=>{
|
||||||
|
state++;
|
||||||
|
});
|
||||||
|
}}>
|
||||||
|
fork 1
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button onclick={()=>{
|
||||||
|
forked?.discard?.();
|
||||||
|
forked = fork(()=>{
|
||||||
|
state++;
|
||||||
|
})
|
||||||
|
}}>
|
||||||
|
fork 2
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button onclick={()=>{
|
||||||
|
forked?.commit();
|
||||||
|
}}>commit</button>
|
||||||
|
|
||||||
|
<p>{count}</p>
|
||||||
Loading…
Reference in new issue