File tree Expand file tree Collapse file tree 5 files changed +69
-2
lines changed
test/runtime/samples/await-then-catch-in-slot Expand file tree Collapse file tree 5 files changed +69
-2
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ export default class AwaitBlock extends Node {
6969 const name = this . var ;
7070
7171 const anchor = this . getOrCreateAnchor ( block , parentNode ) ;
72+ const updateMountNode = this . getUpdateMountNode ( anchor ) ;
7273
7374 const params = block . params . join ( ', ' ) ;
7475
@@ -107,7 +108,7 @@ export default class AwaitBlock extends Node {
107108 ${ old_block } .u();
108109 ${ old_block } .d();
109110 ${ await_block } .c();
110- ${ await_block } .m(${ parentNode || ` ${ anchor } .parentNode` } , ${ anchor } );
111+ ${ await_block } .m(${ updateMountNode } , ${ anchor } );
111112 }
112113 }
113114
Original file line number Diff line number Diff line change 11import { stringify } from '../../utils/stringify' ;
22import Node from './shared/Node' ;
33import Block from '../dom/Block' ;
4- import { State } from '../dom/interfaces' ;
54
65// Whitespace inside one of these elements will not result in
76// a whitespace node being created in any circumstances. (This
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