mirror of https://github.com/sveltejs/svelte
parent
0166bc4850
commit
abe01a76e9
@ -0,0 +1,13 @@
|
|||||||
|
<script>
|
||||||
|
let { count } = $props();
|
||||||
|
|
||||||
|
let [obj, invalidate] = $state.opaque({ count: 0 });
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
invalidate((obj) => {
|
||||||
|
obj.count = count;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>{obj.count}</p>
|
@ -0,0 +1,18 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `<p>0</p><button>+1</button>`,
|
||||||
|
|
||||||
|
test({ assert, target }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
|
||||||
|
button?.click();
|
||||||
|
flushSync();
|
||||||
|
assert.htmlEqual(target.innerHTML, `<p>1</p><button>+1</button>`);
|
||||||
|
|
||||||
|
button?.click();
|
||||||
|
flushSync();
|
||||||
|
assert.htmlEqual(target.innerHTML, `<p>2</p><button>+1</button>`);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,8 @@
|
|||||||
|
<script>
|
||||||
|
import Child from './Child.svelte';
|
||||||
|
|
||||||
|
let count = $state(0);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Child {count} />
|
||||||
|
<button onclick={() => count += 1}>+1</button>
|
Loading…
Reference in new issue