diff --git a/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts b/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts index 321f7fd9ff..ff835ddef6 100644 --- a/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts +++ b/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts @@ -137,6 +137,7 @@ export default class AwaitBlockWrapper extends Wrapper { const info_props = [ 'ctx', 'current: null', + 'token: null', this.pending.block.name && `pending: ${this.pending.block.name}`, this.then.block.name && `then: ${this.then.block.name}`, this.catch.block.name && `catch: ${this.catch.block.name}`, @@ -223,6 +224,7 @@ export default class AwaitBlockWrapper extends Wrapper { block.builders.destroy.add_block(deindent` ${info}.block.d(${parent_node ? '' : 'detaching'}); + ${info}.token = null; ${info} = null; `); diff --git a/test/runtime/index.js b/test/runtime/index.js index 87be528a61..0699dffad7 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -21,6 +21,11 @@ let compile = null; const sveltePath = process.cwd().split('\\').join('/'); +let unhandled_rejection = false; +process.on('unhandledRejection', err => { + unhandled_rejection = err; +}); + describe("runtime", () => { before(() => { svelte = loadSvelte(false); @@ -60,6 +65,8 @@ describe("runtime", () => { throw new Error('skipping test, already failed'); } + unhandled_rejection = null; + compile = (config.preserveIdentifiers ? svelte : svelte$).compile; const cwd = path.resolve(`test/runtime/samples/${dir}`); @@ -165,10 +172,18 @@ describe("runtime", () => { raf })).then(() => { component.$destroy(); + + if (unhandled_rejection) { + throw unhandled_rejection; + } }); } else { component.$destroy(); assert.htmlEqual(target.innerHTML, ""); + + if (unhandled_rejection) { + throw unhandled_rejection; + } } }) .catch(err => { diff --git a/test/runtime/samples/await-in-removed-if/_config.js b/test/runtime/samples/await-in-removed-if/_config.js new file mode 100644 index 0000000000..2f96f08e24 --- /dev/null +++ b/test/runtime/samples/await-in-removed-if/_config.js @@ -0,0 +1,22 @@ +let fulfil; + +const promise = new Promise(f => { + fulfil = f; +}); + +export default { + props: { + promise + }, + + html: ``, + + async test({ assert, component, target }) { + component.condition = false; + + fulfil(); + await new Promise(f => setTimeout(f, 0)); + + assert.htmlEqual(target.innerHTML, ``); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/await-in-removed-if/main.svelte b/test/runtime/samples/await-in-removed-if/main.svelte new file mode 100644 index 0000000000..e854b6feab --- /dev/null +++ b/test/runtime/samples/await-in-removed-if/main.svelte @@ -0,0 +1,8 @@ + + +{#if condition} + {#await promise then _}hello{/await} +{/if} \ No newline at end of file