Merge pull request #454 from taylorzane/gh-452-fix-empty-computed

Fixed empty component 'computed' from throwing error.
pull/449/merge
Rich Harris 8 years ago committed by GitHub
commit 6802f43e48

@ -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 );`
);

@ -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();
}
};

@ -0,0 +1,14 @@
<div>empty</div>
<script>
export default {
data () {
return {};
},
computed: {},
oncreate () {
this.set({ created: true });
}
};
</script>
Loading…
Cancel
Save