File tree Expand file tree Collapse file tree 2 files changed +9
-17
lines changed
packages/svelte/tests/runtime-runes/samples/async-top-level Expand file tree Collapse file tree 2 files changed +9
-17
lines changed Original file line number Diff line number Diff line change 1
1
import { tick } from 'svelte' ;
2
- import { deferred } from '../../../../src/internal/shared/utils.js' ;
3
2
import { test } from '../../test' ;
4
3
5
- /** @type {ReturnType<typeof deferred> } */
6
- let d ;
7
-
8
4
export default test ( {
9
- html : `<p>pending</p>` ,
10
-
11
- get props ( ) {
12
- d = deferred ( ) ;
13
-
14
- return {
15
- promise : d . promise
16
- } ;
17
- } ,
5
+ html : `<button>hello</button><p>pending</p>` ,
18
6
19
7
async test ( { assert, target } ) {
20
- d . resolve ( 'hello' ) ;
8
+ const [ hello ] = target . querySelectorAll ( 'button' ) ;
9
+
10
+ hello . click ( ) ;
21
11
await tick ( ) ;
22
- assert . htmlEqual ( target . innerHTML , '<p>hello</p>' ) ;
12
+ assert . htmlEqual ( target . innerHTML , '<button>hello</button>< p>hello</p>' ) ;
23
13
}
24
14
} ) ;
Original file line number Diff line number Diff line change 1
1
<script >
2
2
import Child from ' ./Child.svelte' ;
3
3
4
- let { promise } = $props ( );
4
+ let deferred = $state ( Promise . withResolvers () );
5
5
</script >
6
6
7
+ <button onclick ={() => deferred .resolve (' hello' )}>hello</button >
8
+
7
9
<svelte:boundary >
8
- <Child { promise } />
10
+ <Child promise ={ deferred . promise } />
9
11
10
12
{#snippet pending ()}
11
13
<p >pending</p >
You can’t perform that action at this time.
0 commit comments