mirror of https://github.com/sveltejs/svelte
parent
435da13fdd
commit
2cd6ddf9eb
@ -0,0 +1,10 @@
|
|||||||
|
<script>
|
||||||
|
class Y {
|
||||||
|
foo = $state(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
let y = $derived(new Y());
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => y.foo++}>click</button>
|
||||||
|
<p>{y.foo}</p>
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
skip_no_async: true,
|
||||||
|
async test({ assert, target }) {
|
||||||
|
const forkButton = target.querySelector('button');
|
||||||
|
|
||||||
|
flushSync(() => {
|
||||||
|
forkButton?.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
const [, clickButton] = target.querySelectorAll('button');
|
||||||
|
const p = target.querySelector('p');
|
||||||
|
|
||||||
|
assert.equal(p?.textContent, '0');
|
||||||
|
|
||||||
|
flushSync(() => {
|
||||||
|
clickButton?.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(p?.textContent, '1');
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
<script>
|
||||||
|
import { fork } from 'svelte';
|
||||||
|
import Child from './Child.svelte';
|
||||||
|
|
||||||
|
let x = $state(false);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => {
|
||||||
|
const f = fork(() => {
|
||||||
|
x = true;
|
||||||
|
});
|
||||||
|
f.commit();
|
||||||
|
}}>fork</button>
|
||||||
|
|
||||||
|
{#if x}
|
||||||
|
<Child />
|
||||||
|
{/if}
|
||||||
Loading…
Reference in new issue