diff --git a/src/generators/nodes/AwaitBlock.ts b/src/generators/nodes/AwaitBlock.ts index 3b928f7804ed..445767d27fdc 100644 --- a/src/generators/nodes/AwaitBlock.ts +++ b/src/generators/nodes/AwaitBlock.ts @@ -127,8 +127,10 @@ export default class AwaitBlock extends Node { if (@isPromise(${promise})) { ${promise}.then(function(${value}) { + var state = #component.get(); ${replace_await_block}(${token}, ${create_then_block}, ${value}, ${params}); }, function (${error}) { + var state = #component.get(); ${replace_await_block}(${token}, ${create_catch_block}, ${error}, ${params}); }); diff --git a/test/runtime/samples/await-set-simultaneous/_config.js b/test/runtime/samples/await-set-simultaneous/_config.js new file mode 100644 index 000000000000..97f79f6119e8 --- /dev/null +++ b/test/runtime/samples/await-set-simultaneous/_config.js @@ -0,0 +1,16 @@ +export default { + test(assert, component, target) { + const promise = Promise.resolve().then(() => component.set({ answer: 42 })); + + component.set({ promise }); + + assert.htmlEqual(target.innerHTML, `

wait for it...

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

the answer is 42!

+ `); + }); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/await-set-simultaneous/main.html b/test/runtime/samples/await-set-simultaneous/main.html new file mode 100644 index 000000000000..3740a904804d --- /dev/null +++ b/test/runtime/samples/await-set-simultaneous/main.html @@ -0,0 +1,9 @@ +{{#if promise}} + {{#await promise}} +

wait for it...

+ {{then _}} +

the answer is {{answer}}!

+ {{catch error}} +

well that's odd

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