Skip to content

Commit

Permalink
remove components without props from each block - fixes #3035
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jun 25, 2019
1 parent 35001b3 commit 7696c1f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/compile/render_dom/wrappers/EachBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ export default class EachBlockWrapper extends Wrapper {
`);
remove_old_blocks = deindent`
@group_outros();
for (; #i < ${view_length}; #i += 1) ${out}(#i);
for (#i = ${this.vars.each_block_value}.${length}; #i < ${view_length}; #i += 1) ${out}(#i);
@check_outros();
`;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>hello</p>
10 changes: 10 additions & 0 deletions test/runtime/samples/each-block-component-no-props/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
html: `
<p>hello</p>
`,

async test({ assert, component, target }) {
await component.remove();
assert.htmlEqual(target.innerHTML, ``);
}
};
13 changes: 13 additions & 0 deletions test/runtime/samples/each-block-component-no-props/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script>
import Child from './Child.svelte';
let items = [1];
export function remove() {
items = [];
}
</script>

{#each items as item}
<Child/>
{/each}

0 comments on commit 7696c1f

Please sign in to comment.