mirror of https://github.com/sveltejs/svelte
parent
02e9f00fd6
commit
bd35fc2440
@ -0,0 +1,16 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<button>increment</button><p>a: 1</p><p>b: 2</p><p>c: 3</p>`,
|
||||
|
||||
test({ assert, target }) {
|
||||
const button = target.querySelector('button');
|
||||
|
||||
flushSync(() => button?.click());
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<button>increment</button><p>a: 2</p><p>b: 3</p><p>c: 4</p>`
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
let offset = $state(1);
|
||||
|
||||
function* count(offset) {
|
||||
let i = offset;
|
||||
while (true) yield i++;
|
||||
}
|
||||
|
||||
let [a, b, c] = $derived(count(offset));
|
||||
</script>
|
||||
|
||||
<button onclick={() => offset += 1}>increment</button>
|
||||
|
||||
<p>a: {a}</p>
|
||||
<p>b: {b}</p>
|
||||
<p>c: {c}</p>
|
Loading…
Reference in new issue