Skip to content

Commit

Permalink
Fixes sveltejs#452. Fixed an issue that caused setting computed to …
Browse files Browse the repository at this point in the history
…an empty object to prevent the component from compiling.
  • Loading branch information
taylorzane committed Apr 5, 2017
1 parent d105b6b commit 3ed4dc6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/generators/dom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export default function dom ( parsed, source, options ) {
constructorBlock.addBlock( generator.builders.metaBindings );
}

if ( templateProperties.computed ) {
if ( computations.length ) {
constructorBlock.addLine(
`${generator.alias( 'recompute' )}( this._state, this._state, {}, true );`
);
Expand Down
8 changes: 8 additions & 0 deletions test/generator/samples/computed-empty/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
html: '<div>empty</div>',
test ( assert, component, target ) {
assert.equal( component.get( 'created' ), true );
assert.equal( target.innerHTML, '<div>empty</div>' );
component.destroy();
}
};
14 changes: 14 additions & 0 deletions test/generator/samples/computed-empty/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div>empty</div>
<script>
export default {
data () {
return {};
},

computed: {},

oncreate () {
this.set({ created: true });
}
};
</script>

0 comments on commit 3ed4dc6

Please sign in to comment.