diff --git a/src/shared/index.js b/src/shared/index.js
index d55e55c22b..f9d0f91998 100644
--- a/src/shared/index.js
+++ b/src/shared/index.js
@@ -156,9 +156,12 @@ export function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ 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) {
diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle.js b/test/js/samples/collapses-text-around-comments/expected-bundle.js
index 7fb59ff390..a5776bc195 100644
--- a/test/js/samples/collapses-text-around-comments/expected-bundle.js
+++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js
@@ -157,9 +157,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js
index c3a2661cc5..94f69ca2ca 100644
--- a/test/js/samples/component-static/expected-bundle.js
+++ b/test/js/samples/component-static/expected-bundle.js
@@ -133,9 +133,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js
index 8a703ed250..c378d78026 100644
--- a/test/js/samples/computed-collapsed-if/expected-bundle.js
+++ b/test/js/samples/computed-collapsed-if/expected-bundle.js
@@ -133,9 +133,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js
index 6fa07bfcdb..11ffa87f21 100644
--- a/test/js/samples/css-media-query/expected-bundle.js
+++ b/test/js/samples/css-media-query/expected-bundle.js
@@ -153,9 +153,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js
index 89287471cb..86edac7465 100644
--- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js
+++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js
@@ -145,9 +145,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js
index c73357a79d..f421b344b2 100644
--- a/test/js/samples/each-block-changed-check/expected-bundle.js
+++ b/test/js/samples/each-block-changed-check/expected-bundle.js
@@ -165,9 +165,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js
index 24b32d9b1a..46c109100a 100644
--- a/test/js/samples/event-handlers-custom/expected-bundle.js
+++ b/test/js/samples/event-handlers-custom/expected-bundle.js
@@ -145,9 +145,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js
index aea386c29a..0277095a83 100644
--- a/test/js/samples/if-block-no-update/expected-bundle.js
+++ b/test/js/samples/if-block-no-update/expected-bundle.js
@@ -149,9 +149,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js
index be77d10110..40acbe3959 100644
--- a/test/js/samples/if-block-simple/expected-bundle.js
+++ b/test/js/samples/if-block-simple/expected-bundle.js
@@ -149,9 +149,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js
index e36eec0994..eff6f53cfa 100644
--- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js
+++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js
@@ -149,9 +149,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/inline-style-optimized-url/expected-bundle.js b/test/js/samples/inline-style-optimized-url/expected-bundle.js
index cbd51d1473..3a126946ad 100644
--- a/test/js/samples/inline-style-optimized-url/expected-bundle.js
+++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js
@@ -149,9 +149,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js
index 7dd9e42578..0c127a6391 100644
--- a/test/js/samples/inline-style-optimized/expected-bundle.js
+++ b/test/js/samples/inline-style-optimized/expected-bundle.js
@@ -149,9 +149,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js
index 8d383eb38b..d6f545111a 100644
--- a/test/js/samples/inline-style-unoptimized/expected-bundle.js
+++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js
@@ -149,9 +149,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/input-without-blowback-guard/expected-bundle.js b/test/js/samples/input-without-blowback-guard/expected-bundle.js
index 4b42f9e572..03756ad56c 100644
--- a/test/js/samples/input-without-blowback-guard/expected-bundle.js
+++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js
@@ -153,9 +153,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js
index 19c61b0d19..7211738f45 100644
--- a/test/js/samples/legacy-input-type/expected-bundle.js
+++ b/test/js/samples/legacy-input-type/expected-bundle.js
@@ -151,9 +151,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/legacy-quote-class/expected-bundle.js b/test/js/samples/legacy-quote-class/expected-bundle.js
index a88e843b6f..1575bf4064 100644
--- a/test/js/samples/legacy-quote-class/expected-bundle.js
+++ b/test/js/samples/legacy-quote-class/expected-bundle.js
@@ -168,9 +168,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js
index 19b7247c74..92eb665731 100644
--- a/test/js/samples/media-bindings/expected-bundle.js
+++ b/test/js/samples/media-bindings/expected-bundle.js
@@ -161,9 +161,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js
index 549c018e7e..575be613fa 100644
--- a/test/js/samples/non-imported-component/expected-bundle.js
+++ b/test/js/samples/non-imported-component/expected-bundle.js
@@ -147,9 +147,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js
index 6199e5061f..f1e701bd04 100644
--- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js
+++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js
@@ -133,9 +133,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js
index 3ec6edbb1b..0c545ea70c 100644
--- a/test/js/samples/setup-method/expected-bundle.js
+++ b/test/js/samples/setup-method/expected-bundle.js
@@ -133,9 +133,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle.js b/test/js/samples/use-elements-as-anchors/expected-bundle.js
index 0529108287..8805cc3847 100644
--- a/test/js/samples/use-elements-as-anchors/expected-bundle.js
+++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js
@@ -157,9 +157,12 @@ function _set(newState) {
this._state = assign({}, oldState, newState);
this._recompute(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);
- dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+
+ if (this._fragment) {
+ dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
+ this._fragment.p(changed, this._state);
+ dispatchObservers(this, this._observers.post, changed, this._state, oldState);
+ }
}
function callAll(fns) {
diff --git a/test/runtime/samples/component-binding-self-destroying/Nested.html b/test/runtime/samples/component-binding-self-destroying/Nested.html
new file mode 100644
index 0000000000..3fb5ca4da3
--- /dev/null
+++ b/test/runtime/samples/component-binding-self-destroying/Nested.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/test/runtime/samples/component-binding-self-destroying/_config.js b/test/runtime/samples/component-binding-self-destroying/_config.js
new file mode 100644
index 0000000000..27a7ab108e
--- /dev/null
+++ b/test/runtime/samples/component-binding-self-destroying/_config.js
@@ -0,0 +1,27 @@
+export default {
+ data: {
+ show: true
+ },
+
+ html: `
+
+ `,
+
+ 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, `
+
+ `);
+
+ target.querySelector('button').dispatchEvent(click);
+
+ assert.equal(component.get('show'), true);
+ assert.htmlEqual(target.innerHTML, `
+
+ `);
+ }
+};
diff --git a/test/runtime/samples/component-binding-self-destroying/main.html b/test/runtime/samples/component-binding-self-destroying/main.html
new file mode 100644
index 0000000000..74fa144d02
--- /dev/null
+++ b/test/runtime/samples/component-binding-self-destroying/main.html
@@ -0,0 +1,14 @@
+{{#if show}}
+
+{{else}}
+
+{{/if}}
+
+
\ No newline at end of file