File tree 4 files changed +69
-1
lines changed
test/runtime/samples/await-then-catch-in-slot
4 files changed +69
-1
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ export default class AwaitBlock extends Node {
69
69
const name = this . var ;
70
70
71
71
const anchor = this . getOrCreateAnchor ( block , parentNode ) ;
72
+ const updateMountNode = this . getUpdateMountNode ( anchor ) ;
72
73
73
74
const params = block . params . join ( ', ' ) ;
74
75
@@ -107,7 +108,7 @@ export default class AwaitBlock extends Node {
107
108
${ old_block } .u();
108
109
${ old_block } .d();
109
110
${ await_block } .c();
110
- ${ await_block } .m(${ parentNode || ` ${ anchor } .parentNode` } , ${ anchor } );
111
+ ${ await_block } .m(${ updateMountNode } , ${ anchor } );
111
112
}
112
113
}
113
114
Original file line number Diff line number Diff line change
1
+ < slot > </ slot >
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
+ ` ,
15
+
16
+ test ( assert , component , target ) {
17
+ fulfil ( 42 ) ;
18
+
19
+ return thePromise
20
+ . then ( ( ) => {
21
+ assert . htmlEqual ( target . innerHTML , `
22
+ <p>the value is 42</p>
23
+ ` ) ;
24
+
25
+ let reject ;
26
+
27
+ thePromise = new Promise ( ( f , r ) => {
28
+ reject = r ;
29
+ } ) ;
30
+
31
+ component . set ( {
32
+ thePromise
33
+ } ) ;
34
+
35
+ assert . htmlEqual ( target . innerHTML , `
36
+ <p>loading...</p>
37
+ ` ) ;
38
+
39
+ reject ( new Error ( 'something broke' ) ) ;
40
+
41
+ return thePromise . catch ( ( ) => { } ) ;
42
+ } )
43
+ . then ( ( ) => {
44
+ assert . htmlEqual ( target . innerHTML , `
45
+ <p>oh no! something broke</p>
46
+ ` ) ;
47
+ } ) ;
48
+ }
49
+ } ;
Original file line number Diff line number Diff line change
1
+ < Foo >
2
+ {{#await thePromise}}
3
+ < p > loading...</ p >
4
+ {{then theValue}}
5
+ < p > the value is {{theValue}}</ p >
6
+ {{catch theError}}
7
+ < p > oh no! {{theError.message}}</ p >
8
+ {{/await}}
9
+ </ Foo >
10
+
11
+ < script >
12
+ import Foo from './Foo.html' ;
13
+
14
+ export default {
15
+ components : { Foo }
16
+ } ;
17
+ </ script >
You can’t perform that action at this time.
0 commit comments