mirror of https://github.com/sveltejs/svelte
parent
ec77f8bdf1
commit
d0d9a3642c
@ -0,0 +1,18 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
async test({ assert, target, logs }) {
|
||||||
|
const [btn, btn2] = target.querySelectorAll('button');
|
||||||
|
|
||||||
|
flushSync(() => {
|
||||||
|
btn.click();
|
||||||
|
});
|
||||||
|
assert.deepEqual(logs, ['foo', 'baz']);
|
||||||
|
|
||||||
|
flushSync(() => {
|
||||||
|
btn2.click();
|
||||||
|
});
|
||||||
|
assert.deepEqual(logs, ['foo', 'baz', 'foo', 'baz']);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,15 @@
|
|||||||
|
<script>
|
||||||
|
let foo = $state({ bar: 1 }, {
|
||||||
|
onchange(){
|
||||||
|
console.log("foo");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let baz = $state(foo, {
|
||||||
|
onchange(){
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={()=> foo.bar++}>foo</button>
|
||||||
|
<button onclick={()=> baz.bar++}>baz</button>
|
Loading…
Reference in new issue