From 23b2817989e52665d66f3bb7ceaa43103bbdc90c Mon Sep 17 00:00:00 2001 From: Petter Ekrann Date: Wed, 11 Oct 2017 08:46:14 +0200 Subject: [PATCH 1/3] Ensure cloning of incomming data Please verify syntax --- src/generators/dom/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index 8e0ec3404c7b..5c381b366d24 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -190,10 +190,10 @@ export default function dom( `if (!options || (!options.target && !options._root)) throw new Error("'target' is a required option");`} @init(this, options); ${generator.usesRefs && `this.refs = {};`} - this._state = ${templateProperties.data - ? `@assign(%data(), options.data)` - : `options.data || {}`}; - ${generator.metaBindings} + + this._state =`@assign({},(%data||%noop)(),options.data)`; + + ${generator.metaBindings} ${computations.length && `this._recompute({ ${Array.from(computationDeps).map(dep => `${dep}: 1`).join(', ')} }, this._state);`} ${options.dev && Array.from(generator.expectedProperties).map( From 0fd823d66176b1787d89c91d8c12cab88ed7ce1c Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 15 Oct 2017 16:17:39 -0400 Subject: [PATCH 2/3] fix syntax --- src/generators/dom/index.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index 5c381b366d24..7c7c4a45dc8d 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -190,10 +190,8 @@ export default function dom( `if (!options || (!options.target && !options._root)) throw new Error("'target' is a required option");`} @init(this, options); ${generator.usesRefs && `this.refs = {};`} - - this._state =`@assign({},(%data||%noop)(),options.data)`; - - ${generator.metaBindings} + this._state = @assign(${templateProperties.data ? '%data()' : '{}'}, options.data); + ${generator.metaBindings} ${computations.length && `this._recompute({ ${Array.from(computationDeps).map(dep => `${dep}: 1`).join(', ')} }, this._state);`} ${options.dev && Array.from(generator.expectedProperties).map( From 2800b5cacceb10bf2c1bb3477df3104ca82f1058 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 15 Oct 2017 16:17:48 -0400 Subject: [PATCH 3/3] update tests --- test/js/samples/component-static/expected-bundle.js | 2 +- test/js/samples/component-static/expected.js | 2 +- test/js/samples/computed-collapsed-if/expected-bundle.js | 2 +- test/js/samples/computed-collapsed-if/expected.js | 2 +- test/js/samples/css-media-query/expected-bundle.js | 2 +- test/js/samples/css-media-query/expected.js | 2 +- test/js/samples/css-shadow-dom-keyframes/expected-bundle.js | 2 +- test/js/samples/css-shadow-dom-keyframes/expected.js | 2 +- test/js/samples/each-block-changed-check/expected-bundle.js | 2 +- test/js/samples/each-block-changed-check/expected.js | 2 +- test/js/samples/event-handlers-custom/expected-bundle.js | 2 +- test/js/samples/event-handlers-custom/expected.js | 2 +- test/js/samples/if-block-no-update/expected-bundle.js | 2 +- test/js/samples/if-block-no-update/expected.js | 2 +- test/js/samples/if-block-simple/expected-bundle.js | 2 +- test/js/samples/if-block-simple/expected.js | 2 +- .../samples/inline-style-optimized-multiple/expected-bundle.js | 2 +- test/js/samples/inline-style-optimized-multiple/expected.js | 2 +- test/js/samples/inline-style-optimized-url/expected-bundle.js | 2 +- test/js/samples/inline-style-optimized-url/expected.js | 2 +- test/js/samples/inline-style-optimized/expected-bundle.js | 2 +- test/js/samples/inline-style-optimized/expected.js | 2 +- test/js/samples/inline-style-unoptimized/expected-bundle.js | 2 +- test/js/samples/inline-style-unoptimized/expected.js | 2 +- test/js/samples/input-without-blowback-guard/expected-bundle.js | 2 +- test/js/samples/input-without-blowback-guard/expected.js | 2 +- test/js/samples/legacy-input-type/expected-bundle.js | 2 +- test/js/samples/legacy-input-type/expected.js | 2 +- test/js/samples/legacy-quote-class/expected-bundle.js | 2 +- test/js/samples/legacy-quote-class/expected.js | 2 +- test/js/samples/media-bindings/expected-bundle.js | 2 +- test/js/samples/media-bindings/expected.js | 2 +- test/js/samples/non-imported-component/expected-bundle.js | 2 +- test/js/samples/non-imported-component/expected.js | 2 +- .../js/samples/onrender-onteardown-rewritten/expected-bundle.js | 2 +- test/js/samples/onrender-onteardown-rewritten/expected.js | 2 +- test/js/samples/setup-method/expected-bundle.js | 2 +- test/js/samples/setup-method/expected.js | 2 +- test/js/samples/use-elements-as-anchors/expected-bundle.js | 2 +- test/js/samples/use-elements-as-anchors/expected.js | 2 +- 40 files changed, 40 insertions(+), 40 deletions(-) diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index 12c0a0cd4b89..d26e5c6c95de 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -198,7 +198,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); if (!options._root) { this._oncreate = []; diff --git a/test/js/samples/component-static/expected.js b/test/js/samples/component-static/expected.js index 039ef606ed7c..421a7adda6c8 100644 --- a/test/js/samples/component-static/expected.js +++ b/test/js/samples/component-static/expected.js @@ -33,7 +33,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); if (!options._root) { this._oncreate = []; diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 41c35ea754b3..d2d76eb00333 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -191,7 +191,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._recompute({ x: 1 }, this._state); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index bc3fcc37d5e9..c2f5e3c2be9b 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -26,7 +26,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._recompute({ x: 1 }, this._state); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index 862f721ebc75..95fad711ca37 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -226,7 +226,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); if (!document.getElementById("svelte-2363328337-style")) add_css(); diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index 5b77893900cd..3c36f9c6ce7c 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -41,7 +41,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); if (!document.getElementById("svelte-2363328337-style")) add_css(); 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 4c8fad71f796..cbcd06b93bf6 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -205,7 +205,7 @@ class SvelteComponent extends HTMLElement { constructor(options = {}) { super(); init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ``; diff --git a/test/js/samples/css-shadow-dom-keyframes/expected.js b/test/js/samples/css-shadow-dom-keyframes/expected.js index c004ec7df61b..d921b0e79fa0 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected.js @@ -28,7 +28,7 @@ class SvelteComponent extends HTMLElement { constructor(options = {}) { super(); init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ``; 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 33bd98ba7457..8c0bd0b2cbcc 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -338,7 +338,7 @@ function create_each_block(state, comments, comment, i, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index 37c12c1acd30..be8a4943b594 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -141,7 +141,7 @@ function create_each_block(state, comments, comment, i, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index a712f5b742d3..275a0377c717 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -223,7 +223,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index 3739ada3a6d3..f7862efb627b 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -46,7 +46,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); 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 f68dbd24e390..a9077ff2ac49 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -271,7 +271,7 @@ function select_block_type(state) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index 6a0a4456c5a4..8f030e4e5336 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -90,7 +90,7 @@ function select_block_type(state) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 9c99dd0275f1..c0ff5cc5a994 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -247,7 +247,7 @@ function create_if_block(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index 9bfd8e211d9c..0b9fbece701e 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -66,7 +66,7 @@ function create_if_block(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); 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 80998f97b2d1..adeb003a8de8 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -220,7 +220,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/inline-style-optimized-multiple/expected.js b/test/js/samples/inline-style-optimized-multiple/expected.js index a92f5d305338..77173460e2e7 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected.js +++ b/test/js/samples/inline-style-optimized-multiple/expected.js @@ -39,7 +39,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); 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 236aaee071b5..6ec70a5669c8 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -215,7 +215,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/inline-style-optimized-url/expected.js b/test/js/samples/inline-style-optimized-url/expected.js index e10acd8dd8d3..bed00356f6be 100644 --- a/test/js/samples/inline-style-optimized-url/expected.js +++ b/test/js/samples/inline-style-optimized-url/expected.js @@ -34,7 +34,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js index f8084094be5d..2e8ef6da17ef 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -215,7 +215,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/inline-style-optimized/expected.js b/test/js/samples/inline-style-optimized/expected.js index e9d42fec079f..7f873e296c1f 100644 --- a/test/js/samples/inline-style-optimized/expected.js +++ b/test/js/samples/inline-style-optimized/expected.js @@ -34,7 +34,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js index d0b2a2dcfe23..bf78dac074b0 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -226,7 +226,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/inline-style-unoptimized/expected.js b/test/js/samples/inline-style-unoptimized/expected.js index b2b4f5ad53e0..4c4d38d2bfe2 100644 --- a/test/js/samples/inline-style-unoptimized/expected.js +++ b/test/js/samples/inline-style-unoptimized/expected.js @@ -45,7 +45,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); 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 792342604d82..fd043c760ef4 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -226,7 +226,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/input-without-blowback-guard/expected.js b/test/js/samples/input-without-blowback-guard/expected.js index f9ae72b1bdd0..247935ffbe96 100644 --- a/test/js/samples/input-without-blowback-guard/expected.js +++ b/test/js/samples/input-without-blowback-guard/expected.js @@ -41,7 +41,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index 26f30cf1944e..a6b6ae4d0597 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -213,7 +213,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/legacy-input-type/expected.js b/test/js/samples/legacy-input-type/expected.js index 5309c86cfd1e..719f550044e7 100644 --- a/test/js/samples/legacy-input-type/expected.js +++ b/test/js/samples/legacy-input-type/expected.js @@ -30,7 +30,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/legacy-quote-class/expected-bundle.js b/test/js/samples/legacy-quote-class/expected-bundle.js index 3be6136b4ac0..b10d66007604 100644 --- a/test/js/samples/legacy-quote-class/expected-bundle.js +++ b/test/js/samples/legacy-quote-class/expected-bundle.js @@ -238,7 +238,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/legacy-quote-class/expected.js b/test/js/samples/legacy-quote-class/expected.js index 82eebe600c3a..0b49103c4762 100644 --- a/test/js/samples/legacy-quote-class/expected.js +++ b/test/js/samples/legacy-quote-class/expected.js @@ -38,7 +38,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index 820db0a4fe4c..068c1b4b15c3 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -302,7 +302,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); if (!options._root) { this._oncreate = []; diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index 832826ffd5e6..bcab29fb7504 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -109,7 +109,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); if (!options._root) { this._oncreate = []; diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 0aefe73b0674..3793f0c102c0 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -221,7 +221,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); if (!options._root) { this._oncreate = []; diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index 1f0745714964..234a824e6c74 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -45,7 +45,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); if (!options._root) { this._oncreate = []; diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index 28dafe0c0d8c..59fbfcf41fec 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -187,7 +187,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._handlers.destroy = [ondestroy]; diff --git a/test/js/samples/onrender-onteardown-rewritten/expected.js b/test/js/samples/onrender-onteardown-rewritten/expected.js index 95f923e4d465..19b85a62e01d 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected.js @@ -22,7 +22,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._handlers.destroy = [ondestroy] diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 42eed6868b4b..7724d9f3ac32 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -199,7 +199,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/setup-method/expected.js b/test/js/samples/setup-method/expected.js index f49817bb990a..092a32ed3b63 100644 --- a/test/js/samples/setup-method/expected.js +++ b/test/js/samples/setup-method/expected.js @@ -34,7 +34,7 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); 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 92e3f9bbd3e0..1f56c0ba7bc1 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -437,7 +437,7 @@ function create_if_block_4(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js index f23b9ec205c7..d2609c45b056 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -248,7 +248,7 @@ function create_if_block_4(state, component) { function SvelteComponent(options) { init(this, options); - this._state = options.data || {}; + this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this);