File tree Expand file tree Collapse file tree 3 files changed +49
-1
lines changed
src/compiler/compile/render_dom/wrappers
test/runtime/samples/await-then-destruct-object-if Expand file tree Collapse file tree 3 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ class AwaitBlockBranch extends Wrapper {
96
96
` ) ;
97
97
this . block . chunks . declarations . push ( b `${ get_context } (#ctx)` ) ;
98
98
if ( this . block . has_update_method ) {
99
- this . block . chunks . update . push ( b `${ get_context } (#ctx)` ) ;
99
+ this . block . chunks . update . unshift ( b `${ get_context } (#ctx)` ) ;
100
100
}
101
101
}
102
102
}
Original file line number Diff line number Diff line change
1
+ export default {
2
+ props : {
3
+ thePromise : Promise . resolve ( { result : 1 } )
4
+ } ,
5
+
6
+ html : '' ,
7
+
8
+ async test ( { assert, component, target } ) {
9
+ await ( component . thePromise = Promise . resolve ( { result : 1 } ) ) ;
10
+
11
+ assert . htmlEqual (
12
+ target . innerHTML ,
13
+ `
14
+ <p>result: 1</p>
15
+ <p>count: 0</p>
16
+ `
17
+ ) ;
18
+
19
+ await new Promise ( resolve => setTimeout ( resolve , 1 ) ) ;
20
+
21
+ assert . htmlEqual (
22
+ target . innerHTML ,
23
+ `
24
+ <p>result: 1</p>
25
+ <p>count: 1</p>
26
+ `
27
+ ) ;
28
+ }
29
+ } ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ export let thePromise;
3
+
4
+ let count = 0 ;
5
+
6
+ setTimeout (() => {
7
+ count++ ;
8
+ }, 0 );
9
+ </script >
10
+
11
+ {#await thePromise then { result }}
12
+ {#if result }
13
+ <p >result: {result }</p >
14
+ <p >count: {count }</p >
15
+ {:else }
16
+ <p >result: {result }</p >
17
+ <p >count: {count }</p >
18
+ {/if }
19
+ {/await }
You can’t perform that action at this time.
0 commit comments