check component exists after _bind before continuing - fixes #917

pull/921/head
Rich Harris 7 years ago
parent 3442df92cb
commit 96428312ec

@ -156,9 +156,12 @@ export function _set(newState) {
this._state = assign({}, oldState, newState); this._state = assign({}, oldState, newState);
this._recompute(changed, this._state); this._recompute(changed, this._state);
if (this._bind) this._bind(changed, this._state); if (this._bind) this._bind(changed, this._state);
dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
this._fragment.p(changed, this._state); if (this._fragment) {
dispatchObservers(this, this._observers.post, changed, this._state, oldState); dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
this._fragment.p(changed, this._state);
dispatchObservers(this, this._observers.post, changed, this._state, oldState);
}
} }
export function _setDev(newState) { export function _setDev(newState) {

@ -0,0 +1 @@
<button on:click="set({show:false})">Hide</button>

@ -0,0 +1,29 @@
export default {
solo: true,
data: {
show: true
},
html: `
<button>Hide</button>
`,
test(assert, component, target, window) {
const click = new window.MouseEvent('click');
target.querySelector('button').dispatchEvent(click);
assert.equal(component.get('show'), false);
assert.htmlEqual(target.innerHTML, `
<button>Show</button>
`);
target.querySelector('button').dispatchEvent(click);
assert.equal(component.get('show'), true);
assert.htmlEqual(target.innerHTML, `
<button>Hide</button>
`);
}
};

@ -0,0 +1,14 @@
{{#if show}}
<Nested bind:show/>
{{else}}
<button on:click="set({show:true})">Show</button>
{{/if}}
<script>
import Nested from './Nested.html';
export default {
components: {
Nested
}
};
</script>
Loading…
Cancel
Save