Skip to content

Commit

Permalink
Merge pull request #1533 from sveltejs/gh-1532
Browse files Browse the repository at this point in the history
call outrocallback immediately for empty each block
  • Loading branch information
Rich-Harris authored Jun 8, 2018
2 parents b76f074 + f8ca0d4 commit 65592aa
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/shared/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function isPromise(value) {
}

export function callAfter(fn, i) {
if (i === 0) fn();
return () => {
if (!--i) fn();
};
Expand Down
1 change: 1 addition & 0 deletions test/runtime/samples/each-block-empty-outro/Thing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>{thing}</p>
20 changes: 20 additions & 0 deletions test/runtime/samples/each-block-empty-outro/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
data: {
visible: true,
empty: []
},

html: `
<div>
<p>text</p>
</div>
`,

nestedTransitions: true,

test(assert, component, target) {
component.set({ visible: false });

assert.htmlEqual(target.innerHTML, ``);
}
};
17 changes: 17 additions & 0 deletions test/runtime/samples/each-block-empty-outro/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{#if visible}
<div>
{#each empty as thing}
<Thing {thing}/>
{/each}

<p>text</p>
</div>
{/if}

<script>
export default {
components: {
Thing: './Thing.html'
}
};
</script>

0 comments on commit 65592aa

Please sign in to comment.