File tree 3 files changed +69
-1
lines changed
src/generators/dom/visitors
test/runtime/samples/await-then-catch-multiple 3 files changed +69
-1
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ export default function visitAwaitBlock(
110
110
const anchorNode = state . parentNode ? 'null' : 'anchor' ;
111
111
112
112
block . builders . mount . addBlock ( deindent `
113
- ${ await_block } .m(${ targetNode } , ${ anchor } );
113
+ ${ await_block } .m(${ targetNode } , ${ anchorNode } );
114
114
` ) ;
115
115
116
116
const conditions = [ ] ;
Original file line number Diff line number Diff line change
1
+ let fulfil ;
2
+
3
+ let thePromise = new Promise ( f => {
4
+ fulfil = f ;
5
+ } ) ;
6
+
7
+ export default {
8
+ data : {
9
+ thePromise
10
+ } ,
11
+
12
+ html : `
13
+ <p>loading...</p>
14
+ <p>loading...</p>
15
+ ` ,
16
+
17
+ test ( assert , component , target ) {
18
+ fulfil ( 42 ) ;
19
+
20
+ return thePromise
21
+ . then ( ( ) => {
22
+ assert . htmlEqual ( target . innerHTML , `
23
+ <p>the value is 42</p>
24
+ <p>the value is 42</p>
25
+ ` ) ;
26
+
27
+ let reject ;
28
+
29
+ thePromise = new Promise ( ( f , r ) => {
30
+ reject = r ;
31
+ } ) ;
32
+
33
+ component . set ( {
34
+ thePromise
35
+ } ) ;
36
+
37
+ assert . htmlEqual ( target . innerHTML , `
38
+ <p>loading...</p>
39
+ <p>loading...</p>
40
+ ` ) ;
41
+
42
+ reject ( new Error ( 'something broke' ) ) ;
43
+
44
+ return thePromise . catch ( ( ) => { } ) ;
45
+ } )
46
+ . then ( ( ) => {
47
+ assert . htmlEqual ( target . innerHTML , `
48
+ <p>oh no! something broke</p>
49
+ <p>oh no! something broke</p>
50
+ ` ) ;
51
+ } ) ;
52
+ }
53
+ } ;
Original file line number Diff line number Diff line change
1
+ {{#await thePromise}}
2
+ < p > loading...</ p >
3
+ {{then theValue}}
4
+ < p > the value is {{theValue}}</ p >
5
+ {{catch theError}}
6
+ < p > oh no! {{theError.message}}</ p >
7
+ {{/await}}
8
+
9
+ {{#await thePromise}}
10
+ < p > loading...</ p >
11
+ {{then theValue}}
12
+ < p > the value is {{theValue}}</ p >
13
+ {{catch theError}}
14
+ < p > oh no! {{theError.message}}</ p >
15
+ {{/await}}
You can’t perform that action at this time.
0 commit comments