Skip to content

Commit

Permalink
Merge pull request #647 from sveltejs/gh-643
Browse files Browse the repository at this point in the history
#643 redux
  • Loading branch information
Rich-Harris authored Jun 17, 2017
2 parents 30d855b + 3c36b77 commit af1f87b
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 13 deletions.
9 changes: 5 additions & 4 deletions src/generators/dom/visitors/IfBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,12 @@ function compound(
`);
}

block.builders.unmount.addLine(
`${if_name}${name}.unmount();`
);

block.builders.destroy.addLine(
`${if_name}{
${name}.unmount();
${name}.destroy();
}`
`${if_name}${name}.destroy();`
);
}

Expand Down
6 changes: 2 additions & 4 deletions test/js/samples/if-block-no-update/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,12 @@ function create_main_fragment ( state, component ) {
},

unmount: function () {
if_block.unmount();
detachNode( if_block_anchor );
},

destroy: function () {
{
if_block.unmount();
if_block.destroy();
}
if_block.destroy();
}
};
}
Expand Down
8 changes: 3 additions & 5 deletions test/js/samples/if-block-no-update/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ function create_main_fragment ( state, component ) {
},

unmount: function () {
if_block.unmount();
detachNode( if_block_anchor );
},

destroy: function () {
{
if_block.unmount();
if_block.destroy();
}
if_block.destroy();
}
};
}
Expand Down Expand Up @@ -116,4 +114,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio
this._torndown = true;
};

export default SvelteComponent;
export default SvelteComponent;
22 changes: 22 additions & 0 deletions test/runtime/samples/component-nested-deeper/Level1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div class="level1">
{{#each values as value}}
<h4>level 1 #{{value}}</h4>
<Level2 condition="{{value % 2}}">
<Level3>
<span>And more stuff goes in here</span>
</Level3>
</Level2>
{{/each}}
</div>

<script>
import Level2 from './Level2.html';
import Level3 from './Level3.html';

export default {
components: {
Level2,
Level3
}
};
</script>
8 changes: 8 additions & 0 deletions test/runtime/samples/component-nested-deeper/Level2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="level2" ref:wat>
<h4>level 2</h4>
{{#if condition}}
<span>TRUE! {{yield}}</span>
{{else}}
<span>FALSE! {{yield}}</span>
{{/if}}
</div>
4 changes: 4 additions & 0 deletions test/runtime/samples/component-nested-deeper/Level3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="level3" ref:thingy>
<h4>level 3</h4>
{{yield}}
</div>
9 changes: 9 additions & 0 deletions test/runtime/samples/component-nested-deeper/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
data: {
values: [1, 2, 3, 4]
},

test(assert, component) {
component.set({ values: [2, 3] });
}
};
11 changes: 11 additions & 0 deletions test/runtime/samples/component-nested-deeper/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Level1 :values/>

<script>
import Level1 from './Level1.html';

export default {
components: {
Level1
}
}
</script>

0 comments on commit af1f87b

Please sign in to comment.