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 c6c7723883..59faec43c0 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -115,9 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } 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 35b70e4100..6e24c4c163 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -91,9 +91,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } 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 b5a15f5630..8aeafdeb12 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -124,9 +124,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } 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 6019667c51..de76233275 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -109,9 +109,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } 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 53cca6fa20..5c46a788ad 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -115,9 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } 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 9636f3d99a..723df41e99 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -115,9 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } 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 04bd9f8588..1b29740949 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -103,9 +103,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { @@ -194,9 +197,13 @@ function SvelteComponent ( options ) { this._fragment.mount( options.target, null ); } - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); + if ( !options._root ) { + this._block = true; + callAll(this._beforecreate); + callAll(this._oncreate); + callAll(this._aftercreate); + this._block = false; + } } assign( SvelteComponent.prototype, proto ); diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index 61c2cceee1..065ebc0a72 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -76,9 +76,13 @@ function SvelteComponent ( options ) { this._fragment.mount( options.target, null ); } - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); + if ( !options._root ) { + this._block = true; + callAll(this._beforecreate); + callAll(this._oncreate); + callAll(this._aftercreate); + this._block = false; + } } assign( SvelteComponent.prototype, proto ); diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index 02ccad5144..61de8b261e 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -91,9 +91,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { @@ -159,7 +162,10 @@ function SvelteComponent ( options ) { this._fragment.create(); this._fragment.mount( options.target, null ); } - callAll(this._oncreate); + + if ( !options._root ) { + callAll(this._oncreate); + } } assign( SvelteComponent.prototype, proto ); diff --git a/test/js/samples/onrender-onteardown-rewritten/expected.js b/test/js/samples/onrender-onteardown-rewritten/expected.js index ff00f93928..1a1c10f7d6 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected.js @@ -51,7 +51,10 @@ function SvelteComponent ( options ) { this._fragment.create(); this._fragment.mount( options.target, null ); } - callAll(this._oncreate); + + if ( !options._root ) { + callAll(this._oncreate); + } } assign( SvelteComponent.prototype, proto ); 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 ec2ceaf4af..8a42c00e2a 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -115,9 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { diff --git a/test/runtime/index.js b/test/runtime/index.js index 16d5820f0b..dea60082a3 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -137,10 +137,9 @@ describe("runtime", () => { throw err; } + let usedObjectAssign = false; Object.assign = () => { - throw new Error( - "cannot use Object.assign in generated code, as it is not supported everywhere" - ); + usedObjectAssign = true; }; global.window = window; @@ -182,14 +181,18 @@ describe("runtime", () => { assert.htmlEqual(target.innerHTML, config.html); } - Object.assign = Object_assign; - if (config.test) { config.test(assert, component, target, window, raf); } else { component.destroy(); assert.equal(target.innerHTML, ""); } + + if (usedObjectAssign) { + throw new Error( + "cannot use Object.assign in generated code, as it is not supported everywhere" + ); + } }) .catch(err => { Object.assign = Object_assign;