File tree 4 files changed +47
-0
lines changed
src/compiler/compile/render_dom/wrappers
samples/await-in-removed-if
4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ export default class AwaitBlockWrapper extends Wrapper {
137
137
const info_props = [
138
138
'ctx' ,
139
139
'current: null' ,
140
+ 'token: null' ,
140
141
this . pending . block . name && `pending: ${ this . pending . block . name } ` ,
141
142
this . then . block . name && `then: ${ this . then . block . name } ` ,
142
143
this . catch . block . name && `catch: ${ this . catch . block . name } ` ,
@@ -223,6 +224,7 @@ export default class AwaitBlockWrapper extends Wrapper {
223
224
224
225
block . builders . destroy . add_block ( deindent `
225
226
${ info } .block.d(${ parent_node ? '' : 'detaching' } );
227
+ ${ info } .token = null;
226
228
${ info } = null;
227
229
` ) ;
228
230
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ let compile = null;
21
21
22
22
const sveltePath = process . cwd ( ) . split ( '\\' ) . join ( '/' ) ;
23
23
24
+ let unhandled_rejection = false ;
25
+ process . on ( 'unhandledRejection' , err => {
26
+ unhandled_rejection = err ;
27
+ } ) ;
28
+
24
29
describe ( "runtime" , ( ) => {
25
30
before ( ( ) => {
26
31
svelte = loadSvelte ( false ) ;
@@ -60,6 +65,8 @@ describe("runtime", () => {
60
65
throw new Error ( 'skipping test, already failed' ) ;
61
66
}
62
67
68
+ unhandled_rejection = null ;
69
+
63
70
compile = ( config . preserveIdentifiers ? svelte : svelte$ ) . compile ;
64
71
65
72
const cwd = path . resolve ( `test/runtime/samples/${ dir } ` ) ;
@@ -165,10 +172,18 @@ describe("runtime", () => {
165
172
raf
166
173
} ) ) . then ( ( ) => {
167
174
component . $destroy ( ) ;
175
+
176
+ if ( unhandled_rejection ) {
177
+ throw unhandled_rejection ;
178
+ }
168
179
} ) ;
169
180
} else {
170
181
component . $destroy ( ) ;
171
182
assert . htmlEqual ( target . innerHTML , "" ) ;
183
+
184
+ if ( unhandled_rejection ) {
185
+ throw unhandled_rejection ;
186
+ }
172
187
}
173
188
} )
174
189
. catch ( err => {
Original file line number Diff line number Diff line change
1
+ let fulfil ;
2
+
3
+ const promise = new Promise ( f => {
4
+ fulfil = f ;
5
+ } ) ;
6
+
7
+ export default {
8
+ props : {
9
+ promise
10
+ } ,
11
+
12
+ html : `` ,
13
+
14
+ async test ( { assert, component, target } ) {
15
+ component . condition = false ;
16
+
17
+ fulfil ( ) ;
18
+ await new Promise ( f => setTimeout ( f , 0 ) ) ;
19
+
20
+ assert . htmlEqual ( target . innerHTML , `` ) ;
21
+ }
22
+ } ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ export let promise;
3
+ export let condition = true ;
4
+ </script >
5
+
6
+ {#if condition }
7
+ {#await promise then _ }hello{/await }
8
+ {/if }
You can’t perform that action at this time.
0 commit comments