From 542dba436a2bcb2ced84e77e5a336c658e1694cb Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Fri, 4 Jan 2019 22:57:40 -0500 Subject: [PATCH] set parent correctly for children of await blocks - should fix #1939 --- src/compile/render-dom/wrappers/AwaitBlock.ts | 2 +- .../samples/await-containing-if/_config.js | 35 +++++++++++++++++++ .../samples/await-containing-if/main.html | 11 ++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/await-containing-if/_config.js create mode 100644 test/runtime/samples/await-containing-if/main.html diff --git a/src/compile/render-dom/wrappers/AwaitBlock.ts b/src/compile/render-dom/wrappers/AwaitBlock.ts index ca1fdcc64e..cbc03f8ce9 100644 --- a/src/compile/render-dom/wrappers/AwaitBlock.ts +++ b/src/compile/render-dom/wrappers/AwaitBlock.ts @@ -80,7 +80,7 @@ export default class AwaitBlockWrapper extends Wrapper { status, renderer, block, - parent, + this, child, stripWhitespace, nextSibling diff --git a/test/runtime/samples/await-containing-if/_config.js b/test/runtime/samples/await-containing-if/_config.js new file mode 100644 index 0000000000..9e24e4f614 --- /dev/null +++ b/test/runtime/samples/await-containing-if/_config.js @@ -0,0 +1,35 @@ +let fulfil; + +let thePromise = new Promise(f => { + fulfil = f; +}); + +export default { + props: { + thePromise, + show: true + }, + + html: ` +

loading...

+ `, + + test({ assert, component, target }) { + fulfil(42); + + return thePromise + .then(() => { + assert.htmlEqual(target.innerHTML, ` +

the value is 42

+ `); + + component.show = false; + assert.htmlEqual(target.innerHTML, `
`); + + component.show = true; + assert.htmlEqual(target.innerHTML, ` +

the value is 42

+ `); + }); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/await-containing-if/main.html b/test/runtime/samples/await-containing-if/main.html new file mode 100644 index 0000000000..cab07e6499 --- /dev/null +++ b/test/runtime/samples/await-containing-if/main.html @@ -0,0 +1,11 @@ +
+ {#await thePromise} +

loading...

+ {:then theValue} + {#if show} +

the value is {theValue}

+ {/if} + {:catch theError} +

oh no! {theError.message}

+ {/await} +
\ No newline at end of file