dont noop set/get until after component is destroyed (fixes #788)

pull/807/head
Rich Harris 7 years ago
parent 865e84b856
commit f5958584d9

@ -5,8 +5,9 @@ export * from './transitions.js';
export * from './utils.js';
export function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -38,8 +38,9 @@ function setAttribute(node, attribute, value) {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -14,8 +14,9 @@ function assign(target) {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -34,8 +34,9 @@ function setAttribute(node, attribute, value) {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -47,8 +47,9 @@ function createText(data) {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -34,8 +34,9 @@ function createText(data) {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -38,8 +38,9 @@ function createComment() {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -38,8 +38,9 @@ function createComment() {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -32,8 +32,9 @@ function setInputType(input, type) {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -28,8 +28,9 @@ function createText(data) {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -14,8 +14,9 @@ function assign(target) {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -14,8 +14,9 @@ function assign(target) {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -38,8 +38,9 @@ function createComment() {
}
function destroy(detach) {
this.destroy = this.set = this.get = noop;
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();

@ -0,0 +1,26 @@
export default {
'skip-ssr': true,
data: {
foo: 1
},
test(assert, component) {
const values = [];
let valueOnDestroy;
component.on('destroy', () => {
component.set({ foo: 2 });
valueOnDestroy = component.get('foo');
});
component.observe('foo', foo => {
values.push(foo);
});
component.destroy();
assert.deepEqual(values, [1, 2]);
assert.equal(valueOnDestroy, 2);
}
};
Loading…
Cancel
Save