From 0e586e39e38da807f8abb4734c53aaaf864eaf47 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Tue, 20 Nov 2018 10:25:49 -0800 Subject: [PATCH 1/3] added test for async block ordering (#1440) --- .../samples/await-then-catch-order/_config.js | 27 +++++++++++++++++++ .../samples/await-then-catch-order/main.html | 11 ++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/runtime/samples/await-then-catch-order/_config.js create mode 100644 test/runtime/samples/await-then-catch-order/main.html diff --git a/test/runtime/samples/await-then-catch-order/_config.js b/test/runtime/samples/await-then-catch-order/_config.js new file mode 100644 index 0000000000..4a8f4df77c --- /dev/null +++ b/test/runtime/samples/await-then-catch-order/_config.js @@ -0,0 +1,27 @@ +let fulfil; + +let thePromise = new Promise(f => { + fulfil = f; +}); + +export default { + data: { + thePromise + }, + + html: ` +

loading...

true!

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

the value is 42

true!

+ `); + }); + + } +}; diff --git a/test/runtime/samples/await-then-catch-order/main.html b/test/runtime/samples/await-then-catch-order/main.html new file mode 100644 index 0000000000..87b37bf27d --- /dev/null +++ b/test/runtime/samples/await-then-catch-order/main.html @@ -0,0 +1,11 @@ +{#await thePromise} +

loading...

+{:then theValue} +

the value is {theValue}

+{:catch theError} +

oh no! {theError.message}

+{/await} + +{#if true} +

true!

+{/if} From 05fa286d7b2f1fdc6b0e62ddf73c61182e790a4f Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Tue, 20 Nov 2018 12:54:55 -0800 Subject: [PATCH 2/3] fixes #1440 --- src/compile/render-dom/wrappers/AwaitBlock.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compile/render-dom/wrappers/AwaitBlock.ts b/src/compile/render-dom/wrappers/AwaitBlock.ts index bfd3143333..50320ee8b6 100644 --- a/src/compile/render-dom/wrappers/AwaitBlock.ts +++ b/src/compile/render-dom/wrappers/AwaitBlock.ts @@ -174,6 +174,9 @@ export default class AwaitBlockWrapper extends Wrapper { block.builders.mount.addBlock(deindent` ${info}.block.${hasTransitions ? 'i' : 'm'}(${initialMountNode}, ${info}.anchor = ${anchorNode}); ${info}.mount = () => ${updateMountNode}; + if (${info}.anchor == null) { + ${info}.anchor = ${anchor}; + } `); const conditions = []; From 68c2a34bda4151cf08e7c0586e5b224dee425bb3 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Tue, 20 Nov 2018 13:28:31 -0800 Subject: [PATCH 3/3] fix transition-js-await-block test --- test/runtime/samples/transition-js-await-block/_config.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/runtime/samples/transition-js-await-block/_config.js b/test/runtime/samples/transition-js-await-block/_config.js index ff9888c88b..6c482afe45 100644 --- a/test/runtime/samples/transition-js-await-block/_config.js +++ b/test/runtime/samples/transition-js-await-block/_config.js @@ -26,10 +26,10 @@ export default { return promise.then(() => { raf.tick(80); let ps = document.querySelectorAll('p'); - assert.equal(ps[0].className, 'pending'); - assert.equal(ps[1].className, 'then'); - assert.equal(ps[0].foo, 0.2); - assert.equal(ps[1].foo, 0.3); + assert.equal(ps[1].className, 'pending'); + assert.equal(ps[0].className, 'then'); + assert.equal(ps[1].foo, 0.2); + assert.equal(ps[0].foo, 0.3); }); } };