Repository: sveltejs/svelte (JavaScript)
Date: 2018-04-22 14:59:45+00:00
Task type: Bug Fix

Issue:
component.get() can return undefined after component destroyed
Since `this.get('foo')` is deprecated (https://github.com/sveltejs/svelte/pull/1347), I've been working on migrating all usages to `let { foo } = this.get()`.

However I've found that the two aren't exactly equivalent, since `this.get()` can actually return `undefined` if the component is destroyed (e.g. because it was called within a `requestIdleCallback()` or `setTimeout()` callback).

Throws an error:

```html
<h1>Hello {name}!</h1>
<script>
	export default {
		oncreate() {
			setTimeout(() => this.destroy(), 1000)
			setTimeout(() => {
				let { name } = this.get() // throws
				console.log('name', name)
			}, 2000)
		}
	}
</script>
```

Doesn't throw an error:

```html
<h1>Hello {name}!</h1>
<script>
	export default {
		oncreate() {
			setTimeout(() => this.destroy(), 1000)
			setTimeout(() => {
				let name = this.get('name') // does not throw
				console.log('name', name)
			}, 2000)
		}
	}
</script>
```

So far, my workaround has been to do `let { foo } = this.get() || {}` but it would be nice if it were just automatically wrapped in an empty object so that the two forms were equivalent.


Issue discussion:
Related: it would be useful to be able to know within an asynchronous callback whether the component was destroyed or not, without having to attach an `on('destroy')` listener. (I notice https://github.com/sveltejs/svelte/pull/948 was not merged.)
Can we combine these two problems into a solution? Does `component.get()` always return undefined after the component has been destroyed?
I'm not sure. What I am sure about is that _if_ the component is destroyed, then `component.get()` is undefined. I'm not sure where exactly in the lifecycle it gets set to undefined, i.e. if it's right before getting destroyed, right after, etc.

In any case, I would _prefer_ not to have to think about every place in my code where the component might have been destroyed (i.e. to wrap `component.get()` in a `component.destroyed` check or similar), but maybe that's not practical.
I also just fell into this.
It would be great to have the way to know if component was destroyed.
Getting undefined within component.get() may be a solution.
Let's keep it

Solution patch:
diff --git a/src/shared/index.js b/src/shared/index.js
--- a/src/shared/index.js
+++ b/src/shared/index.js
@@ -13,11 +13,12 @@ export function blankObject() {
 export function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 export function destroyDev(detach) {


Test patch:
diff --git a/test/js/samples/action/expected-bundle.js b/test/js/samples/action/expected-bundle.js
--- a/test/js/samples/action/expected-bundle.js
+++ b/test/js/samples/action/expected-bundle.js
@@ -24,11 +24,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle.js b/test/js/samples/collapses-text-around-comments/expected-bundle.js
--- a/test/js/samples/collapses-text-around-comments/expected-bundle.js
+++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js
@@ -32,11 +32,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js
--- a/test/js/samples/component-static-immutable/expected-bundle.js
+++ b/test/js/samples/component-static-immutable/expected-bundle.js
@@ -12,11 +12,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js
--- a/test/js/samples/component-static-immutable2/expected-bundle.js
+++ b/test/js/samples/component-static-immutable2/expected-bundle.js
@@ -12,11 +12,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js
--- a/test/js/samples/component-static/expected-bundle.js
+++ b/test/js/samples/component-static/expected-bundle.js
@@ -12,11 +12,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js
--- a/test/js/samples/computed-collapsed-if/expected-bundle.js
+++ b/test/js/samples/computed-collapsed-if/expected-bundle.js
@@ -12,11 +12,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js
--- a/test/js/samples/css-media-query/expected-bundle.js
+++ b/test/js/samples/css-media-query/expected-bundle.js
@@ -28,11 +28,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js
--- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js
+++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js
@@ -24,11 +24,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js
--- a/test/js/samples/deconflict-builtins/expected-bundle.js
+++ b/test/js/samples/deconflict-builtins/expected-bundle.js
@@ -42,11 +42,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js
--- a/test/js/samples/deconflict-globals/expected-bundle.js
+++ b/test/js/samples/deconflict-globals/expected-bundle.js
@@ -12,11 +12,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js
--- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js
+++ b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js
@@ -32,11 +32,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function destroyDev(detach) {
diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js
--- a/test/js/samples/do-use-dataset/expected-bundle.js
+++ b/test/js/samples/do-use-dataset/expected-bundle.js
@@ -28,11 +28,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js
--- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js
+++ b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js
@@ -32,11 +32,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js
--- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js
+++ b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js
@@ -32,11 +32,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js
--- a/test/js/samples/each-block-changed-check/expected-bundle.js
+++ b/test/js/samples/each-block-changed-check/expected-bundle.js
@@ -44,11 +44,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js
--- a/test/js/samples/event-handlers-custom/expected-bundle.js
+++ b/test/js/samples/event-handlers-custom/expected-bundle.js
@@ -24,11 +24,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js
--- a/test/js/samples/head-no-whitespace/expected-bundle.js
+++ b/test/js/samples/head-no-whitespace/expected-bundle.js
@@ -24,11 +24,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js
--- a/test/js/samples/if-block-no-update/expected-bundle.js
+++ b/test/js/samples/if-block-no-update/expected-bundle.js
@@ -28,11 +28,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js
--- a/test/js/samples/if-block-simple/expected-bundle.js
+++ b/test/js/samples/if-block-simple/expected-bundle.js
@@ -28,11 +28,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js
--- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js
+++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js
@@ -28,11 +28,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/inline-style-optimized-url/expected-bundle.js b/test/js/samples/inline-style-optimized-url/expected-bundle.js
--- a/test/js/samples/inline-style-optimized-url/expected-bundle.js
+++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js
@@ -28,11 +28,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js
--- a/test/js/samples/inline-style-optimized/expected-bundle.js
+++ b/test/js/samples/inline-style-optimized/expected-bundle.js
@@ -28,11 +28,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js
--- a/test/js/samples/inline-style-unoptimized/expected-bundle.js
+++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js
@@ -28,11 +28,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/input-without-blowback-guard/expected-bundle.js b/test/js/samples/input-without-blowback-guard/expected-bundle.js
--- a/test/js/samples/input-without-blowback-guard/expected-bundle.js
+++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js
@@ -36,11 +36,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js
--- a/test/js/samples/legacy-input-type/expected-bundle.js
+++ b/test/js/samples/legacy-input-type/expected-bundle.js
@@ -30,11 +30,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js
--- a/test/js/samples/media-bindings/expected-bundle.js
+++ b/test/js/samples/media-bindings/expected-bundle.js
@@ -40,11 +40,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js
--- a/test/js/samples/non-imported-component/expected-bundle.js
+++ b/test/js/samples/non-imported-component/expected-bundle.js
@@ -26,11 +26,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js
--- a/test/js/samples/setup-method/expected-bundle.js
+++ b/test/js/samples/setup-method/expected-bundle.js
@@ -12,11 +12,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js
--- a/test/js/samples/svg-title/expected-bundle.js
+++ b/test/js/samples/svg-title/expected-bundle.js
@@ -32,11 +32,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js
--- a/test/js/samples/title/expected-bundle.js
+++ b/test/js/samples/title/expected-bundle.js
@@ -12,11 +12,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle.js b/test/js/samples/use-elements-as-anchors/expected-bundle.js
--- a/test/js/samples/use-elements-as-anchors/expected-bundle.js
+++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js
@@ -36,11 +36,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js
--- a/test/js/samples/window-binding-scroll/expected-bundle.js
+++ b/test/js/samples/window-binding-scroll/expected-bundle.js
@@ -32,11 +32,12 @@ function blankObject() {
 function destroy(detach) {
 	this.destroy = noop;
 	this.fire('destroy');
-	this.set = this.get = noop;
+	this.set = noop;
 
 	if (detach !== false) this._fragment.u();
 	this._fragment.d();
-	this._fragment = this._state = null;
+	this._fragment = null;
+	this._state = {};
 }
 
 function _differs(a, b) {
diff --git a/test/runtime/samples/get-after-destroy/_config.js b/test/runtime/samples/get-after-destroy/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/get-after-destroy/_config.js
@@ -0,0 +1,13 @@
+export default {
+	data: {
+		foo: 1
+	},
+
+	html: `<div>1</div>`,
+
+	test(assert, component) {
+		component.destroy();
+		const { foo } = component.get();
+		assert.equal(foo, undefined);
+	}
+}
\ No newline at end of file
diff --git a/test/runtime/samples/get-after-destroy/main.html b/test/runtime/samples/get-after-destroy/main.html
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/get-after-destroy/main.html
@@ -0,0 +1 @@
+<div>{foo}</div>
\ No newline at end of file