diff --git a/src/generators/dom/visitors/AwaitBlock.ts b/src/generators/dom/visitors/AwaitBlock.ts index b4372831a8..c0d5c25b85 100644 --- a/src/generators/dom/visitors/AwaitBlock.ts +++ b/src/generators/dom/visitors/AwaitBlock.ts @@ -110,7 +110,7 @@ export default function visitAwaitBlock( const anchorNode = state.parentNode ? 'null' : 'anchor'; block.builders.mount.addBlock(deindent` - ${await_block}.m(${targetNode}, ${anchor}); + ${await_block}.m(${targetNode}, ${anchorNode}); `); const conditions = []; diff --git a/test/runtime/samples/await-then-catch-multiple/_config.js b/test/runtime/samples/await-then-catch-multiple/_config.js new file mode 100644 index 0000000000..2866fea883 --- /dev/null +++ b/test/runtime/samples/await-then-catch-multiple/_config.js @@ -0,0 +1,53 @@ +let fulfil; + +let thePromise = new Promise(f => { + fulfil = f; +}); + +export default { + data: { + thePromise + }, + + html: ` +
loading...
+loading...
+ `, + + test(assert, component, target) { + fulfil(42); + + return thePromise + .then(() => { + assert.htmlEqual(target.innerHTML, ` +the value is 42
+the value is 42
+ `); + + let reject; + + thePromise = new Promise((f, r) => { + reject = r; + }); + + component.set({ + thePromise + }); + + assert.htmlEqual(target.innerHTML, ` +loading...
+loading...
+ `); + + reject(new Error('something broke')); + + return thePromise.catch(() => {}); + }) + .then(() => { + assert.htmlEqual(target.innerHTML, ` +oh no! something broke
+oh no! something broke
+ `); + }); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/await-then-catch-multiple/main.html b/test/runtime/samples/await-then-catch-multiple/main.html new file mode 100644 index 0000000000..eb071c27a8 --- /dev/null +++ b/test/runtime/samples/await-then-catch-multiple/main.html @@ -0,0 +1,15 @@ +{{#await thePromise}} +loading...
+{{then theValue}} +the value is {{theValue}}
+{{catch theError}} +oh no! {{theError.message}}
+{{/await}} + +{{#await thePromise}} +loading...
+{{then theValue}} +the value is {{theValue}}
+{{catch theError}} +oh no! {{theError.message}}
+{{/await}} \ No newline at end of file