mirror of https://github.com/sveltejs/svelte
commit
81f24f4cd1
@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
'svelte': patch
|
|
||||||
---
|
|
||||||
|
|
||||||
fix: properly defer document title until async work is complete
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
'svelte': patch
|
|
||||||
---
|
|
||||||
|
|
||||||
fix: take blockers of components into account
|
|
||||||
@ -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