File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
packages/svelte/tests/runtime-runes/samples/derived-destructured-iterator Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { flushSync } from 'svelte' ;
2
+ import { test } from '../../test' ;
3
+
4
+ export default test ( {
5
+ html : `<button>increment</button><p>a: 1</p><p>b: 2</p><p>c: 3</p>` ,
6
+
7
+ test ( { assert, target } ) {
8
+ const button = target . querySelector ( 'button' ) ;
9
+
10
+ flushSync ( ( ) => button ?. click ( ) ) ;
11
+ assert . htmlEqual (
12
+ target . innerHTML ,
13
+ `<button>increment</button><p>a: 2</p><p>b: 3</p><p>c: 4</p>`
14
+ ) ;
15
+ }
16
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ let offset = $state (1 );
3
+
4
+ function * count (offset ) {
5
+ let i = offset;
6
+ while (true ) yield i++ ;
7
+ }
8
+
9
+ let [a, b, c] = $derived (count (offset));
10
+ </script >
11
+
12
+ <button onclick ={() => offset += 1 }>increment</button >
13
+
14
+ <p >a: {a }</p >
15
+ <p >b: {b }</p >
16
+ <p >c: {c }</p >
You can’t perform that action at this time.
0 commit comments