From 9e877d9da10bb6ed0615a655a5d1f362055c9449 Mon Sep 17 00:00:00 2001 From: Jacob Wright Date: Sat, 10 Feb 2018 12:37:33 -0700 Subject: [PATCH] Makes immutable a component option rather than a compile option This allows components to opt in (or out) of using immutable data checking for greater flexibility in app design. It also removes the compiler option. --- src/generators/Generator.ts | 4 ++ src/generators/dom/index.ts | 3 +- src/interfaces.ts | 1 - src/shared/index.js | 2 + src/validate/js/propValidators/immutable.ts | 11 ++++ src/validate/js/propValidators/index.ts | 2 + .../expected-bundle.js | 7 ++- .../expected.js | 3 +- .../expected-bundle.js | 57 +++++++++++------ .../component-static-immutable/expected.js | 62 +++++++++++++++++++ .../component-static-immutable/input.html | 10 +++ .../component-static/expected-bundle.js | 7 ++- test/js/samples/component-static/expected.js | 3 +- .../_config.js | 5 -- .../expected.js | 49 --------------- .../input.html | 8 --- .../computed-collapsed-if/expected-bundle.js | 7 ++- .../samples/computed-collapsed-if/expected.js | 3 +- .../css-media-query/expected-bundle.js | 7 ++- test/js/samples/css-media-query/expected.js | 3 +- .../expected-bundle.js | 7 ++- .../css-shadow-dom-keyframes/expected.js | 3 +- .../deconflict-globals/expected-bundle.js | 7 ++- .../js/samples/deconflict-globals/expected.js | 3 +- .../samples/do-use-dataset/expected-bundle.js | 7 ++- test/js/samples/do-use-dataset/expected.js | 3 +- .../expected-bundle.js | 7 ++- .../dont-use-dataset-in-legacy/expected.js | 3 +- .../expected-bundle.js | 7 ++- .../dont-use-dataset-in-svg/expected.js | 3 +- .../expected-bundle.js | 7 ++- .../each-block-changed-check/expected.js | 3 +- .../event-handlers-custom/expected-bundle.js | 7 ++- .../samples/event-handlers-custom/expected.js | 3 +- .../head-no-whitespace/expected-bundle.js | 7 ++- .../js/samples/head-no-whitespace/expected.js | 3 +- .../if-block-no-update/expected-bundle.js | 7 ++- .../js/samples/if-block-no-update/expected.js | 3 +- .../if-block-simple/expected-bundle.js | 7 ++- test/js/samples/if-block-simple/expected.js | 3 +- .../expected-bundle.js | 7 ++- .../expected.js | 3 +- .../expected-bundle.js | 7 ++- .../inline-style-optimized-url/expected.js | 3 +- .../inline-style-optimized/expected-bundle.js | 7 ++- .../inline-style-optimized/expected.js | 3 +- .../expected-bundle.js | 7 ++- .../inline-style-unoptimized/expected.js | 3 +- .../expected-bundle.js | 7 ++- .../input-without-blowback-guard/expected.js | 3 +- .../legacy-input-type/expected-bundle.js | 7 ++- test/js/samples/legacy-input-type/expected.js | 3 +- .../legacy-quote-class/expected-bundle.js | 7 ++- .../js/samples/legacy-quote-class/expected.js | 3 +- .../samples/media-bindings/expected-bundle.js | 7 ++- test/js/samples/media-bindings/expected.js | 3 +- .../non-imported-component/expected-bundle.js | 7 ++- .../non-imported-component/expected.js | 3 +- .../expected-bundle.js | 7 ++- .../onrender-onteardown-rewritten/expected.js | 3 +- .../samples/setup-method/expected-bundle.js | 7 ++- test/js/samples/setup-method/expected.js | 3 +- test/js/samples/svg-title/expected-bundle.js | 7 ++- test/js/samples/svg-title/expected.js | 3 +- test/js/samples/title/expected-bundle.js | 7 ++- test/js/samples/title/expected.js | 3 +- .../expected-bundle.js | 7 ++- .../use-elements-as-anchors/expected.js | 3 +- .../window-binding-scroll/expected-bundle.js | 7 ++- .../samples/window-binding-scroll/expected.js | 3 +- 70 files changed, 333 insertions(+), 171 deletions(-) create mode 100644 src/validate/js/propValidators/immutable.ts rename test/js/samples/{computed-collapsed-if-immutable => component-static-immutable}/expected-bundle.js (80%) create mode 100644 test/js/samples/component-static-immutable/expected.js create mode 100644 test/js/samples/component-static-immutable/input.html delete mode 100644 test/js/samples/computed-collapsed-if-immutable/_config.js delete mode 100644 test/js/samples/computed-collapsed-if-immutable/expected.js delete mode 100644 test/js/samples/computed-collapsed-if-immutable/input.html diff --git a/src/generators/Generator.ts b/src/generators/Generator.ts index 1f48424c95..35bb2e9859 100644 --- a/src/generators/Generator.ts +++ b/src/generators/Generator.ts @@ -626,6 +626,10 @@ export default class Generator { addDeclaration('store', templateProperties.store.value); } + if (templateProperties.immutable) { + addDeclaration('immutable', templateProperties.immutable.value); + } + if (templateProperties.tag) { this.tag = templateProperties.tag.value.value; } diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index acf161642d..c1a23784b0 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -207,8 +207,8 @@ export default function dom( ${options.dev && `this._debugName = '${debugName}';`} ${options.dev && !generator.customElement && `if (!options || (!options.target && !options.root)) throw new Error("'target' is a required option");`} + ${templateProperties.immutable && `if (!('immutable' in options)) options = assign({ immutable: %immutable }, options);`} @init(this, options); - this._differs = @differs; ${templateProperties.store && `this.store = %store();`} ${generator.usesRefs && `this.refs = {};`} this._state = @assign(${initialState.join(', ')}); @@ -376,7 +376,6 @@ export default function dom( if (sigil === '@') { if (name in shared) { if (options.dev && `${name}Dev` in shared) name = `${name}Dev`; - else if (options.immutable && `${name}Immutable` in shared) name = `${name}Immutable`; usedHelpers.add(name); } diff --git a/src/interfaces.ts b/src/interfaces.ts index 82de8cd047..9773d330d3 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -52,7 +52,6 @@ export interface CompileOptions { cssOutputFilename?: string; dev?: boolean; - immutable?: boolean; shared?: boolean | string; cascade?: boolean; hydratable?: boolean; diff --git a/src/shared/index.js b/src/shared/index.js index 0005569532..8506a5ed56 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -76,6 +76,8 @@ export function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } export function observe(key, callback, options) { diff --git a/src/validate/js/propValidators/immutable.ts b/src/validate/js/propValidators/immutable.ts new file mode 100644 index 0000000000..20e475340d --- /dev/null +++ b/src/validate/js/propValidators/immutable.ts @@ -0,0 +1,11 @@ +import { Validator } from '../../'; +import { Node } from '../../../interfaces'; + +export default function tag(validator: Validator, prop: Node) { + if (prop.value.type !== 'Literal' || typeof prop.value.value !== 'boolean') { + validator.error( + `'immutable' must be a boolean literal`, + prop.value.start + ); + } +} diff --git a/src/validate/js/propValidators/index.ts b/src/validate/js/propValidators/index.ts index 942c757601..05819b0837 100644 --- a/src/validate/js/propValidators/index.ts +++ b/src/validate/js/propValidators/index.ts @@ -15,6 +15,7 @@ import tag from './tag'; import transitions from './transitions'; import setup from './setup'; import store from './store'; +import immutable from './immutable'; export default { data, @@ -34,4 +35,5 @@ export default { transitions, setup, store, + immutable, }; 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 ba89e7777b..15e441a2b3 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -55,6 +55,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -98,6 +102,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -243,7 +249,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign(data(), options.data); if (!document.getElementById("svelte-2794052100-style")) add_css(); diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index a76fb36edf..aea4721e36 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, createText, detachNode, differs, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; +import { appendNode, assign, createElement, createText, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; function data() { return { foo: 42 } @@ -51,7 +51,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign(data(), options.data); if (!document.getElementById("svelte-2794052100-style")) add_css(); diff --git a/test/js/samples/computed-collapsed-if-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js similarity index 80% rename from test/js/samples/computed-collapsed-if-immutable/expected-bundle.js rename to test/js/samples/component-static-immutable/expected-bundle.js index 509aa9328f..580ce5287b 100644 --- a/test/js/samples/computed-collapsed-if-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -27,6 +27,10 @@ function destroy(detach) { this._fragment = this._state = null; } +function differs(a, b) { + return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + function differsImmutable(a, b) { return a != a ? b == b : a !== b; } @@ -74,6 +78,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -169,50 +175,63 @@ var proto = { }; /* generated by Svelte vX.Y.Z */ -function a(x) { - return x * 2; -} +var Nested = window.Nested; -function b(x) { - return x * 3; -} +var immutable = true; function create_main_fragment(state, component) { + var nested = new Nested({ + root: component.root, + data: { foo: "bar" } + }); + return { - c: noop, + c: function create() { + nested._fragment.c(); + }, - m: noop, + m: function mount(target, anchor) { + nested._mount(target, anchor); + }, p: noop, - u: noop, + u: function unmount() { + nested._unmount(); + }, - d: noop + d: function destroy$$1() { + nested.destroy(false); + } }; } function SvelteComponent(options) { + if (!('immutable' in options)) options = assign({ immutable: immutable }, options); init(this, options); - this._differs = differsImmutable; this._state = assign({}, options.data); - this._recompute({ x: 1 }, this._state); + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } this._fragment = create_main_fragment(this._state, this); if (options.target) { this._fragment.c(); this._fragment.m(options.target, options.anchor || null); + + this._lock = true; + callAll(this._beforecreate); + callAll(this._oncreate); + callAll(this._aftercreate); + this._lock = false; } } assign(SvelteComponent.prototype, proto); -SvelteComponent.prototype._recompute = function _recompute(changed, state) { - if (changed.x) { - if (this._differs(state.a, (state.a = a(state.x)))) changed.a = true; - if (this._differs(state.b, (state.b = b(state.x)))) changed.b = true; - } -}; - export default SvelteComponent; diff --git a/test/js/samples/component-static-immutable/expected.js b/test/js/samples/component-static-immutable/expected.js new file mode 100644 index 0000000000..57ce7c1a85 --- /dev/null +++ b/test/js/samples/component-static-immutable/expected.js @@ -0,0 +1,62 @@ +/* generated by Svelte vX.Y.Z */ +import { assign, callAll, init, noop, proto } from "svelte/shared.js"; + +var Nested = window.Nested; + +var immutable = true; + +function create_main_fragment(state, component) { + + var nested = new Nested({ + root: component.root, + data: { foo: "bar" } + }); + + return { + c: function create() { + nested._fragment.c(); + }, + + m: function mount(target, anchor) { + nested._mount(target, anchor); + }, + + p: noop, + + u: function unmount() { + nested._unmount(); + }, + + d: function destroy() { + nested.destroy(false); + } + }; +} + +function SvelteComponent(options) { + if (!('immutable' in options)) options = assign({ immutable: immutable }, options); + init(this, options); + this._state = assign({}, options.data); + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this._fragment = create_main_fragment(this._state, this); + + if (options.target) { + this._fragment.c(); + this._fragment.m(options.target, options.anchor || null); + + this._lock = true; + callAll(this._beforecreate); + callAll(this._oncreate); + callAll(this._aftercreate); + this._lock = false; + } +} + +assign(SvelteComponent.prototype, proto); +export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/component-static-immutable/input.html b/test/js/samples/component-static-immutable/input.html new file mode 100644 index 0000000000..df6c82ea81 --- /dev/null +++ b/test/js/samples/component-static-immutable/input.html @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index b28b38ddb6..161fc25d9d 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -31,6 +31,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -74,6 +78,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -201,7 +207,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); if (!options.root) { diff --git a/test/js/samples/component-static/expected.js b/test/js/samples/component-static/expected.js index de06c6fb2d..d75cce1253 100644 --- a/test/js/samples/component-static/expected.js +++ b/test/js/samples/component-static/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, callAll, differs, init, noop, proto } from "svelte/shared.js"; +import { assign, callAll, init, noop, proto } from "svelte/shared.js"; var Nested = window.Nested; @@ -33,7 +33,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); if (!options.root) { diff --git a/test/js/samples/computed-collapsed-if-immutable/_config.js b/test/js/samples/computed-collapsed-if-immutable/_config.js deleted file mode 100644 index 06713941e0..0000000000 --- a/test/js/samples/computed-collapsed-if-immutable/_config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - options: { - immutable: true - } -}; \ No newline at end of file diff --git a/test/js/samples/computed-collapsed-if-immutable/expected.js b/test/js/samples/computed-collapsed-if-immutable/expected.js deleted file mode 100644 index b5beba1695..0000000000 --- a/test/js/samples/computed-collapsed-if-immutable/expected.js +++ /dev/null @@ -1,49 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, differsImmutable, init, noop, proto } from "svelte/shared.js"; - -function a(x) { - return x * 2; -} - -function b(x) { - return x * 3; -} - -function create_main_fragment(state, component) { - - return { - c: noop, - - m: noop, - - p: noop, - - u: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._differs = differsImmutable; - this._state = assign({}, options.data); - this._recompute({ x: 1 }, this._state); - - this._fragment = create_main_fragment(this._state, this); - - if (options.target) { - this._fragment.c(); - this._fragment.m(options.target, options.anchor || null); - } -} - -assign(SvelteComponent.prototype, proto); - -SvelteComponent.prototype._recompute = function _recompute(changed, state) { - if (changed.x) { - if (this._differs(state.a, (state.a = a(state.x)))) changed.a = true; - if (this._differs(state.b, (state.b = b(state.x)))) changed.b = true; - } -} -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/computed-collapsed-if-immutable/input.html b/test/js/samples/computed-collapsed-if-immutable/input.html deleted file mode 100644 index a68513b860..0000000000 --- a/test/js/samples/computed-collapsed-if-immutable/input.html +++ /dev/null @@ -1,8 +0,0 @@ - \ No newline at end of file diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 475b5d3491..41cf402472 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -31,6 +31,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -74,6 +78,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -194,7 +200,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._recompute({ x: 1 }, this._state); diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index c0765a4115..085365f4c5 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, differs, init, noop, proto } from "svelte/shared.js"; +import { assign, init, noop, proto } from "svelte/shared.js"; function a(x) { return x * 2; @@ -26,7 +26,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._recompute({ x: 1 }, this._state); diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index cfed183001..f70404e499 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -51,6 +51,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -94,6 +98,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -229,7 +235,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); if (!document.getElementById("svelte-3905933315-style")) add_css(); diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index 61e78032e8..37afa6b42a 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, detachNode, differs, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; +import { appendNode, assign, createElement, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; function encapsulateStyles(node) { setAttribute(node, "svelte-3905933315", ""); @@ -41,7 +41,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); if (!document.getElementById("svelte-3905933315-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 2684f5ddb7..216ad97fe2 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -43,6 +43,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -86,6 +90,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -209,7 +215,6 @@ class SvelteComponent extends HTMLElement { constructor(options = {}) { super(); init(this, options); - this._differs = differs; this._state = assign({}, options.data); this.attachShadow({ mode: 'open' }); diff --git a/test/js/samples/css-shadow-dom-keyframes/expected.js b/test/js/samples/css-shadow-dom-keyframes/expected.js index de4528ff0e..496586e632 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, differs, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var div; @@ -29,7 +29,6 @@ class SvelteComponent extends HTMLElement { constructor(options = {}) { super(); init(this, options); - this._differs = differs; this._state = assign({}, options.data); this.attachShadow({ mode: 'open' }); diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index b3e979c0e9..7769b49deb 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -31,6 +31,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -74,6 +78,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -196,7 +202,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign(data_1(), options.data); var _oncreate = oncreate.bind(this); diff --git a/test/js/samples/deconflict-globals/expected.js b/test/js/samples/deconflict-globals/expected.js index 95da7a1a0c..8730f4e3c3 100644 --- a/test/js/samples/deconflict-globals/expected.js +++ b/test/js/samples/deconflict-globals/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, callAll, differs, init, noop, proto } from "svelte/shared.js"; +import { assign, callAll, init, noop, proto } from "svelte/shared.js"; function data_1() { return { @@ -28,7 +28,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign(data_1(), options.data); var _oncreate = oncreate.bind(this); diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js index 8974c8a808..3b955df698 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -47,6 +47,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -90,6 +94,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -225,7 +231,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/do-use-dataset/expected.js b/test/js/samples/do-use-dataset/expected.js index cbe6e9ac2b..1ae7417469 100644 --- a/test/js/samples/do-use-dataset/expected.js +++ b/test/js/samples/do-use-dataset/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, createText, detachNode, differs, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var div, text, div_1; @@ -41,7 +41,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); 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 index 9f546da356..15c19756cb 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js @@ -51,6 +51,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -94,6 +98,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -229,7 +235,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected.js b/test/js/samples/dont-use-dataset-in-legacy/expected.js index 989b1a47f8..03eef26ced 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, createText, detachNode, differs, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; +import { assign, createElement, createText, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; function create_main_fragment(state, component) { var div, text, div_1; @@ -41,7 +41,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); 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 index e6c5fee0c6..ee846b8fb4 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js @@ -51,6 +51,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -94,6 +98,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -227,7 +233,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/dont-use-dataset-in-svg/expected.js b/test/js/samples/dont-use-dataset-in-svg/expected.js index f96da75975..b87f152298 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createSvgElement, detachNode, differs, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; +import { appendNode, assign, createSvgElement, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; function create_main_fragment(state, component) { var svg, g, g_1; @@ -39,7 +39,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); 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 428e9c739a..d717803108 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -63,6 +63,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -106,6 +110,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -341,7 +347,6 @@ function create_each_block(state, comments, comment, i, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 c436550f07..29a57322e0 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, createText, destroyEach, detachAfter, detachNode, differs, init, insertNode, noop, proto } from "svelte/shared.js"; +import { appendNode, assign, createElement, createText, destroyEach, detachAfter, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var text, p, text_1; @@ -141,7 +141,6 @@ function create_each_block(state, comments, comment, i, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 819b653caa..dbda232f59 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -43,6 +43,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -86,6 +90,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -226,7 +232,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 1d5ae4b17e..f7862efb62 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, differs, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function foo( node, callback ) { // code goes here @@ -46,7 +46,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js index 398617dd13..c0ae2a8ba0 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -43,6 +43,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -86,6 +90,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -216,7 +222,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/head-no-whitespace/expected.js b/test/js/samples/head-no-whitespace/expected.js index d9bee61c62..32a1a5da88 100644 --- a/test/js/samples/head-no-whitespace/expected.js +++ b/test/js/samples/head-no-whitespace/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, detachNode, differs, init, noop, proto } from "svelte/shared.js"; +import { appendNode, assign, createElement, detachNode, init, noop, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var meta, meta_1; @@ -36,7 +36,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 b3dc0c6b13..31d618922e 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -47,6 +47,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -90,6 +94,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -274,7 +280,6 @@ function select_block_type(state) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 59c54d1ad7..8f030e4e53 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createComment, createElement, detachNode, differs, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, createComment, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var if_block_anchor; @@ -90,7 +90,6 @@ function select_block_type(state) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 9dac6d03a9..f36462efad 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -47,6 +47,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -90,6 +94,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -250,7 +256,6 @@ function create_if_block(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 667640451f..0b9fbece70 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createComment, createElement, detachNode, differs, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, createComment, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var if_block_anchor; @@ -66,7 +66,6 @@ function create_if_block(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 8843db047b..57402a155a 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -47,6 +47,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -90,6 +94,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -223,7 +229,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 0b0aca132b..77173460e2 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected.js +++ b/test/js/samples/inline-style-optimized-multiple/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, differs, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; +import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; function create_main_fragment(state, component) { var div; @@ -39,7 +39,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 e88379a4e4..069cc003b7 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -47,6 +47,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -90,6 +94,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -218,7 +224,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 1d8d5c467a..bed00356f6 100644 --- a/test/js/samples/inline-style-optimized-url/expected.js +++ b/test/js/samples/inline-style-optimized-url/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, differs, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; +import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; function create_main_fragment(state, component) { var div; @@ -34,7 +34,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 a1b8278e87..643017655d 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -47,6 +47,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -90,6 +94,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -218,7 +224,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 7f4f19248b..7f873e296c 100644 --- a/test/js/samples/inline-style-optimized/expected.js +++ b/test/js/samples/inline-style-optimized/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, differs, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; +import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; function create_main_fragment(state, component) { var div; @@ -34,7 +34,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 9db0da26fe..906bf21bb5 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -47,6 +47,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -90,6 +94,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -229,7 +235,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 0e53480fe8..4c4d38d2bf 100644 --- a/test/js/samples/inline-style-unoptimized/expected.js +++ b/test/js/samples/inline-style-unoptimized/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, createText, detachNode, differs, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var div, text, div_1, div_1_style_value; @@ -45,7 +45,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 fb3f125b00..a02405f10a 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -51,6 +51,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -94,6 +98,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -229,7 +235,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 9342b25ec9..03f27ab6d9 100644 --- a/test/js/samples/input-without-blowback-guard/expected.js +++ b/test/js/samples/input-without-blowback-guard/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { addListener, assign, createElement, detachNode, differs, init, insertNode, proto, removeListener } from "svelte/shared.js"; +import { addListener, assign, createElement, detachNode, init, insertNode, proto, removeListener } from "svelte/shared.js"; function create_main_fragment(state, component) { var input; @@ -41,7 +41,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 8b6e2faa8f..b54727a24c 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -49,6 +49,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -92,6 +96,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -216,7 +222,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 22d71f036d..719f550044 100644 --- a/test/js/samples/legacy-input-type/expected.js +++ b/test/js/samples/legacy-input-type/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, differs, init, insertNode, noop, proto, setInputType } from "svelte/shared.js"; +import { assign, createElement, detachNode, init, insertNode, noop, proto, setInputType } from "svelte/shared.js"; function create_main_fragment(state, component) { var input; @@ -30,7 +30,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 b4900a16b5..3177f32f16 100644 --- a/test/js/samples/legacy-quote-class/expected-bundle.js +++ b/test/js/samples/legacy-quote-class/expected-bundle.js @@ -66,6 +66,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -109,6 +113,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -241,7 +247,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 c4421f91cd..0b49103c47 100644 --- a/test/js/samples/legacy-quote-class/expected.js +++ b/test/js/samples/legacy-quote-class/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, children, claimElement, createElement, detachNode, differs, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, children, claimElement, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var div; @@ -38,7 +38,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 2eacb53f8c..7a258f8965 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -59,6 +59,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -102,6 +106,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -282,7 +288,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); if (!options.root) { diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index 503228ce06..ae80f288f6 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { addListener, assign, callAll, createElement, detachNode, differs, init, insertNode, proto, removeListener, timeRangesToArray } from "svelte/shared.js"; +import { addListener, assign, callAll, createElement, detachNode, init, insertNode, proto, removeListener, timeRangesToArray } from "svelte/shared.js"; function create_main_fragment(state, component) { var audio, audio_is_paused = true, audio_updating = false, audio_animationframe; @@ -86,7 +86,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); if (!options.root) { diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 9cba5b8bfb..2799a85ebe 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -45,6 +45,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -88,6 +92,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -224,7 +230,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); if (!options.root) { diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index c35b4f88a7..e7fc2c7255 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, callAll, createText, detachNode, differs, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, callAll, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; import Imported from 'Imported.html'; @@ -45,7 +45,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); if (!options.root) { diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index 26f52231fc..049ba0d86a 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -31,6 +31,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -74,6 +78,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -190,7 +196,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 02203f83c0..51763c0b00 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, callAll, differs, init, noop, proto } from "svelte/shared.js"; +import { assign, callAll, init, noop, proto } from "svelte/shared.js"; function oncreate() {}; @@ -22,7 +22,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 103bf174ac..388bb495bc 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -31,6 +31,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -74,6 +78,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -202,7 +208,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 5b306a12e7..092a32ed3b 100644 --- a/test/js/samples/setup-method/expected.js +++ b/test/js/samples/setup-method/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, differs, init, noop, proto } from "svelte/shared.js"; +import { assign, init, noop, proto } from "svelte/shared.js"; var methods = { foo ( bar ) { @@ -34,7 +34,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index 2050f6dcfe..46880a584c 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -51,6 +51,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -94,6 +98,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -217,7 +223,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/svg-title/expected.js b/test/js/samples/svg-title/expected.js index 6c5d08ca00..39ccf227c0 100644 --- a/test/js/samples/svg-title/expected.js +++ b/test/js/samples/svg-title/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createSvgElement, createText, detachNode, differs, init, insertNode, noop, proto } from "svelte/shared.js"; +import { appendNode, assign, createSvgElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var svg, title, text; @@ -29,7 +29,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index 2fcc0b6197..4e70625f70 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -31,6 +31,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -74,6 +78,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -193,7 +199,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/title/expected.js b/test/js/samples/title/expected.js index e15441fbdc..6aa903d25e 100644 --- a/test/js/samples/title/expected.js +++ b/test/js/samples/title/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, differs, init, noop, proto } from "svelte/shared.js"; +import { assign, init, noop, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var title_value; @@ -25,7 +25,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 e22e431d53..2045954b41 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -55,6 +55,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -98,6 +102,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -440,7 +446,6 @@ function create_if_block_4(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; 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 0b45ca8679..d2609c45b0 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createComment, createElement, createText, detachNode, differs, init, insertNode, noop, proto } from "svelte/shared.js"; +import { appendNode, assign, createComment, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var div, text, p, text_2, text_3, text_4, p_1, text_6, text_8, if_block_4_anchor; @@ -248,7 +248,6 @@ function create_if_block_4(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._fragment = create_main_fragment(this._state, this); diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index 97231f4bb6..b0014988b7 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -51,6 +51,10 @@ function differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function differsImmutable(a, b) { + return a != a ? b == b : a !== b; +} + function dispatchObservers(component, group, changed, newState, oldState) { for (var key in group) { if (!changed[key]) continue; @@ -94,6 +98,8 @@ function init(component, options) { component.options = options; component.root = options.root || component; component.store = component.root.store || options.store; + var immutable = options.immutable !== undefined ? options.immutable : component.root.options.immutable; + component._differs = immutable ? differsImmutable : differs; } function observe(key, callback, options) { @@ -241,7 +247,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._state.y = window.scrollY; diff --git a/test/js/samples/window-binding-scroll/expected.js b/test/js/samples/window-binding-scroll/expected.js index 55bc0eb53a..70eae003d7 100644 --- a/test/js/samples/window-binding-scroll/expected.js +++ b/test/js/samples/window-binding-scroll/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, createText, detachNode, differs, init, insertNode, proto } from "svelte/shared.js"; +import { appendNode, assign, createElement, createText, detachNode, init, insertNode, proto } from "svelte/shared.js"; function create_main_fragment(state, component) { var window_updating = false, clear_window_updating = function() { window_updating = false; }, window_updating_timeout, p, text, text_1; @@ -53,7 +53,6 @@ function create_main_fragment(state, component) { function SvelteComponent(options) { init(this, options); - this._differs = differs; this._state = assign({}, options.data); this._state.y = window.scrollY;