mirror of https://github.com/sveltejs/svelte
parent
3e886c71f0
commit
25e03b3fad
@ -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, [[{}, {}, {}, {}, {}, {}, {}, {}]]);
|
||||||
|
|
||||||
|
flushSync(() => {
|
||||||
|
btn2.click();
|
||||||
|
});
|
||||||
|
assert.deepEqual(logs, [[{}, {}, {}, {}, {}, {}, {}, {}], []]);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,14 @@
|
|||||||
|
<script>
|
||||||
|
let array = $state([], {
|
||||||
|
onchange() {
|
||||||
|
console.log($state.snapshot(array));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- clicking either of these buttons should result in at most one log -->
|
||||||
|
<button onclick={() => array = [{}, {}, {}, {}, {}, {}, {}, {}]}>populate array</button>
|
||||||
|
<button onclick={() => array.length = 0}>clear array</button>
|
||||||
|
|
||||||
|
<!-- without this, nested proxies aren't created -->
|
||||||
|
<pre>{JSON.stringify(array)}</pre>
|
Loading…
Reference in new issue