From f8ca0d4efe2ed736c099956df03050a513511e0b Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 7 Jun 2018 08:28:09 -0400 Subject: [PATCH] call outrocallback immediately for empty each block --- src/shared/utils.js | 1 + .../samples/each-block-empty-outro/Thing.html | 1 + .../samples/each-block-empty-outro/_config.js | 20 +++++++++++++++++++ .../samples/each-block-empty-outro/main.html | 17 ++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 test/runtime/samples/each-block-empty-outro/Thing.html create mode 100644 test/runtime/samples/each-block-empty-outro/_config.js create mode 100644 test/runtime/samples/each-block-empty-outro/main.html diff --git a/src/shared/utils.js b/src/shared/utils.js index 436782dcf6..c431a673f8 100644 --- a/src/shared/utils.js +++ b/src/shared/utils.js @@ -15,6 +15,7 @@ export function isPromise(value) { } export function callAfter(fn, i) { + if (i === 0) fn(); return () => { if (!--i) fn(); }; diff --git a/test/runtime/samples/each-block-empty-outro/Thing.html b/test/runtime/samples/each-block-empty-outro/Thing.html new file mode 100644 index 0000000000..150c8fd252 --- /dev/null +++ b/test/runtime/samples/each-block-empty-outro/Thing.html @@ -0,0 +1 @@ +

{thing}

\ No newline at end of file diff --git a/test/runtime/samples/each-block-empty-outro/_config.js b/test/runtime/samples/each-block-empty-outro/_config.js new file mode 100644 index 0000000000..443371892b --- /dev/null +++ b/test/runtime/samples/each-block-empty-outro/_config.js @@ -0,0 +1,20 @@ +export default { + data: { + visible: true, + empty: [] + }, + + html: ` +
+

text

+
+ `, + + nestedTransitions: true, + + test(assert, component, target) { + component.set({ visible: false }); + + assert.htmlEqual(target.innerHTML, ``); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/each-block-empty-outro/main.html b/test/runtime/samples/each-block-empty-outro/main.html new file mode 100644 index 0000000000..b5d1b95260 --- /dev/null +++ b/test/runtime/samples/each-block-empty-outro/main.html @@ -0,0 +1,17 @@ +{#if visible} +
+ {#each empty as thing} + + {/each} + +

text

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