From d643ac784947c045b39dacd03802a87797c8a2ac Mon Sep 17 00:00:00 2001 From: mtrelis Date: Sat, 18 Jan 2020 15:16:45 +0100 Subject: [PATCH] api docs + test --- site/content/docs/02-template-syntax.md | 2 ++ .../samples/transition-js-promise-outro/_config.js | 14 ++++++++++++++ .../transition-js-promise-outro/main.svelte | 14 ++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 test/runtime/samples/transition-js-promise-outro/_config.js create mode 100644 test/runtime/samples/transition-js-promise-outro/main.svelte diff --git a/site/content/docs/02-template-syntax.md b/site/content/docs/02-template-syntax.md index 0a4ca2ee1a..9112689ca0 100644 --- a/site/content/docs/02-template-syntax.md +++ b/site/content/docs/02-template-syntax.md @@ -979,6 +979,8 @@ Similar to `transition:`, but only applies to elements entering (`in:`) or leavi Unlike with `transition:`, transitions applied with `in:` and `out:` are not bidirectional — an in transition will continue to 'play' alongside the out transition, rather than reversing, if the block is outroed while the transition is in progress. If an out transition is aborted, transitions will restart from scratch. +If an `out:` custom transition function returns a promise instead of a transition object, svelte will simply await its completion before unmounting the node. + ```html {#if visible}
diff --git a/test/runtime/samples/transition-js-promise-outro/_config.js b/test/runtime/samples/transition-js-promise-outro/_config.js new file mode 100644 index 0000000000..eba6971476 --- /dev/null +++ b/test/runtime/samples/transition-js-promise-outro/_config.js @@ -0,0 +1,14 @@ +export default { + props: { + visible: true, + }, + + test({ assert, component, target }) { + component.visible = false; + assert.notEqual(target.querySelector('span'), undefined); + component.resolve(); + setTimeout(() => { + assert.equal(target.querySelector('span'), undefined); + }); + }, +}; diff --git a/test/runtime/samples/transition-js-promise-outro/main.svelte b/test/runtime/samples/transition-js-promise-outro/main.svelte new file mode 100644 index 0000000000..80b6cc6f2d --- /dev/null +++ b/test/runtime/samples/transition-js-promise-outro/main.svelte @@ -0,0 +1,14 @@ + + +{#if visible} + hello +{/if}