File tree Expand file tree Collapse file tree 2 files changed +82
-0
lines changed
packages/svelte/tests/runtime-runes/samples/async-time-travelling-derived Expand file tree Collapse file tree 2 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 1+ import { tick } from 'svelte' ;
2+ import { test } from '../../test' ;
3+
4+ export default test ( {
5+ async test ( { assert, target } ) {
6+ await tick ( ) ;
7+
8+ const [ a , b , update ] = target . querySelectorAll ( 'button' ) ;
9+
10+ assert . htmlEqual (
11+ target . innerHTML ,
12+ `
13+ <button>a</button>
14+ <button>b</button>
15+ <button>0</button>
16+ <h1>a</h1>
17+ `
18+ ) ;
19+
20+ b . click ( ) ;
21+ await tick ( ) ;
22+ assert . htmlEqual (
23+ target . innerHTML ,
24+ `
25+ <button>a</button>
26+ <button>b</button>
27+ <button>0</button>
28+ <h1>b</h1>
29+ `
30+ ) ;
31+
32+ update . click ( ) ;
33+ await tick ( ) ;
34+ assert . htmlEqual (
35+ target . innerHTML ,
36+ `
37+ <button>a</button>
38+ <button>b</button>
39+ <button>1</button>
40+ <h1>b</h1>
41+ `
42+ ) ;
43+
44+ a . click ( ) ;
45+ await tick ( ) ;
46+ assert . htmlEqual (
47+ target . innerHTML ,
48+ `
49+ <button>a</button>
50+ <button>b</button>
51+ <button>1</button>
52+ <h1>a</h1>
53+ `
54+ ) ;
55+ }
56+ } ) ;
Original file line number Diff line number Diff line change 1+ <script >
2+ let object = $state (null );
3+ let count = $state (0 );
4+
5+ const condition = $derived (object === null );
6+ </script >
7+
8+ <svelte:boundary >
9+ <button onclick ={() => (object = null )}>a</button >
10+ <button onclick ={() => (object = {})}>b</button >
11+
12+ <button onclick ={async () => {
13+ count ++ ;
14+ await Promise .resolve ();
15+ object = {};
16+ }}>{await count }</button >
17+
18+ {#if condition }
19+ <h1 >a</h1 >
20+ {:else }
21+ <h1 >b</h1 >
22+ {/if }
23+
24+ {#snippet pending ()}{/ snippet }
25+ </svelte:boundary >
26+
You can’t perform that action at this time.
0 commit comments