Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure cloning of incomming data #891

Merged
merged 3 commits into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/generators/dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ 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 || {}`};
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 &&
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/component-static/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/component-static/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/computed-collapsed-if/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/computed-collapsed-if/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/css-media-query/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/css-media-query/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<style>div{animation:foo 1s}@keyframes foo{0%{opacity:0}100%{opacity:1}}</style>`;
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/css-shadow-dom-keyframes/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<style>div{animation:foo 1s}@keyframes foo{0%{opacity:0}100%{opacity:1}}</style>`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/each-block-changed-check/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/event-handlers-custom/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/event-handlers-custom/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/if-block-no-update/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/if-block-no-update/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/if-block-simple/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/if-block-simple/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/inline-style-optimized-url/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/inline-style-optimized/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/inline-style-optimized/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/inline-style-unoptimized/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/input-without-blowback-guard/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/legacy-input-type/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/legacy-input-type/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/legacy-quote-class/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/legacy-quote-class/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/media-bindings/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/media-bindings/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/non-imported-component/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/non-imported-component/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/onrender-onteardown-rewritten/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/setup-method/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/setup-method/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/use-elements-as-anchors/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/use-elements-as-anchors/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down