diff --git a/src/generators/dom/visitors/AwaitBlock.ts b/src/generators/dom/visitors/AwaitBlock.ts index c0d5c25b85..6e014af289 100644 --- a/src/generators/dom/visitors/AwaitBlock.ts +++ b/src/generators/dom/visitors/AwaitBlock.ts @@ -67,7 +67,7 @@ export default function visitAwaitBlock( ${old_block}.u(); ${old_block}.d(); ${await_block}.c(); - ${await_block}.m(${anchor}.parentNode, ${anchor}); + ${await_block}.m(${state.parentNode || `${anchor}.parentNode`}, ${anchor}); } } @@ -142,6 +142,10 @@ export default function visitAwaitBlock( `); } + block.builders.unmount.addBlock(deindent` + ${await_block}.u(); + `); + block.builders.destroy.addBlock(deindent` ${await_token} = null; ${await_block}.d(); diff --git a/test/runtime/samples/await-then-catch-if/_config.js b/test/runtime/samples/await-then-catch-if/_config.js index 1fe94768c3..bbd8d792c6 100644 --- a/test/runtime/samples/await-then-catch-if/_config.js +++ b/test/runtime/samples/await-then-catch-if/_config.js @@ -1,6 +1,6 @@ let fulfil; -let thePromise = new Promise(f => { +const thePromise = new Promise(f => { fulfil = f; }); @@ -35,9 +35,11 @@ export default { show: true }); - assert.htmlEqual(target.innerHTML, ` -

the value is 42

- `); + return thePromise.then(() => { + assert.htmlEqual(target.innerHTML, ` +

the value is 42

+ `); + }); }); } };