From 514ebd28b75f133a8be4e98129bf786218796ba1 Mon Sep 17 00:00:00 2001 From: Jacob Wright Date: Sat, 10 Feb 2018 23:54:33 -0700 Subject: [PATCH] Adding compiler option for immutable back in This will keep existing code smaller and _mostly_ only add size when using the `immutable` compiler option. --- src/generators/dom/index.ts | 5 ++++- src/interfaces.ts | 1 + src/shared/index.js | 3 +-- src/validate/js/propValidators/immutable.ts | 2 +- .../collapses-text-around-comments/expected-bundle.js | 7 +------ test/js/samples/component-static-immutable/_config.js | 5 +++++ .../samples/component-static-immutable/expected-bundle.js | 7 ++++--- test/js/samples/component-static-immutable/expected.js | 6 ++++-- test/js/samples/component-static/expected-bundle.js | 7 +------ test/js/samples/computed-collapsed-if/expected-bundle.js | 7 +------ test/js/samples/css-media-query/expected-bundle.js | 7 +------ .../js/samples/css-shadow-dom-keyframes/expected-bundle.js | 7 +------ test/js/samples/deconflict-globals/expected-bundle.js | 7 +------ test/js/samples/do-use-dataset/expected-bundle.js | 7 +------ .../samples/dont-use-dataset-in-legacy/expected-bundle.js | 7 +------ test/js/samples/dont-use-dataset-in-svg/expected-bundle.js | 7 +------ .../js/samples/each-block-changed-check/expected-bundle.js | 7 +------ test/js/samples/event-handlers-custom/expected-bundle.js | 7 +------ test/js/samples/head-no-whitespace/expected-bundle.js | 7 +------ test/js/samples/if-block-no-update/expected-bundle.js | 7 +------ test/js/samples/if-block-simple/expected-bundle.js | 7 +------ .../inline-style-optimized-multiple/expected-bundle.js | 7 +------ .../samples/inline-style-optimized-url/expected-bundle.js | 7 +------ test/js/samples/inline-style-optimized/expected-bundle.js | 7 +------ .../js/samples/inline-style-unoptimized/expected-bundle.js | 7 +------ .../input-without-blowback-guard/expected-bundle.js | 7 +------ test/js/samples/legacy-input-type/expected-bundle.js | 7 +------ test/js/samples/legacy-quote-class/expected-bundle.js | 7 +------ test/js/samples/media-bindings/expected-bundle.js | 7 +------ test/js/samples/non-imported-component/expected-bundle.js | 7 +------ .../onrender-onteardown-rewritten/expected-bundle.js | 7 +------ test/js/samples/setup-method/expected-bundle.js | 7 +------ test/js/samples/svg-title/expected-bundle.js | 7 +------ test/js/samples/title/expected-bundle.js | 7 +------ test/js/samples/use-elements-as-anchors/expected-bundle.js | 7 +------ test/js/samples/window-binding-scroll/expected-bundle.js | 7 +------ 36 files changed, 49 insertions(+), 183 deletions(-) create mode 100644 test/js/samples/component-static-immutable/_config.js diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index c1a23784b0..dc4dafd536 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -207,8 +207,11 @@ 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); + ${options.immutable && deindent` + if (options.immutable !== undefined ? options.immutable : ${templateProperties.immutable && '%immutable' || 'this.root.options.immutable'}) { + this._differs = @differsImmutable; + }`} ${templateProperties.store && `this.store = %store();`} ${generator.usesRefs && `this.refs = {};`} this._state = @assign(${initialState.join(', ')}); diff --git a/src/interfaces.ts b/src/interfaces.ts index 9773d330d3..82de8cd047 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -52,6 +52,7 @@ 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 8506a5ed56..8996ee378a 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -72,12 +72,11 @@ export function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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 index 20e475340d..b54521d9e4 100644 --- a/src/validate/js/propValidators/immutable.ts +++ b/src/validate/js/propValidators/immutable.ts @@ -1,7 +1,7 @@ import { Validator } from '../../'; import { Node } from '../../../interfaces'; -export default function tag(validator: Validator, prop: Node) { +export default function immutable(validator: Validator, prop: Node) { if (prop.value.type !== 'Literal' || typeof prop.value.value !== 'boolean') { validator.error( `'immutable' must be a boolean literal`, 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 15e441a2b3..72b12b5ef4 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -55,10 +55,6 @@ 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,12 +94,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/component-static-immutable/_config.js b/test/js/samples/component-static-immutable/_config.js new file mode 100644 index 0000000000..06713941e0 --- /dev/null +++ b/test/js/samples/component-static-immutable/_config.js @@ -0,0 +1,5 @@ +export default { + options: { + immutable: true + } +}; \ No newline at end of file diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js index 580ce5287b..500322d902 100644 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -74,12 +74,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { @@ -208,8 +207,10 @@ function create_main_fragment(state, component) { } function SvelteComponent(options) { - if (!('immutable' in options)) options = assign({ immutable: immutable }, options); init(this, options); + if (options.immutable !== undefined ? options.immutable : immutable) { + this._differs = differsImmutable; + } this._state = assign({}, options.data); if (!options.root) { diff --git a/test/js/samples/component-static-immutable/expected.js b/test/js/samples/component-static-immutable/expected.js index 57ce7c1a85..811d5c50c4 100644 --- a/test/js/samples/component-static-immutable/expected.js +++ b/test/js/samples/component-static-immutable/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, callAll, init, noop, proto } from "svelte/shared.js"; +import { assign, callAll, differsImmutable, init, noop, proto } from "svelte/shared.js"; var Nested = window.Nested; @@ -34,8 +34,10 @@ function create_main_fragment(state, component) { } function SvelteComponent(options) { - if (!('immutable' in options)) options = assign({ immutable: immutable }, options); init(this, options); + if (options.immutable !== undefined ? options.immutable : immutable) { + this._differs = differsImmutable; + } this._state = assign({}, options.data); if (!options.root) { diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index 161fc25d9d..b89784944c 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -31,10 +31,6 @@ 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,12 +70,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 41cf402472..b88fbb5e47 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -31,10 +31,6 @@ 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,12 +70,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index f70404e499..606b5dc9e8 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -51,10 +51,6 @@ 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,12 +90,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { 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 216ad97fe2..0cc67aa9bc 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -43,10 +43,6 @@ 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,12 +82,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index 7769b49deb..1a1e25de5a 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -31,10 +31,6 @@ 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,12 +70,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js index 3b955df698..e3532c976a 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -47,10 +47,6 @@ 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,12 +86,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { 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 15c19756cb..df67cf01e8 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,10 +51,6 @@ 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,12 +90,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { 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 ee846b8fb4..55fd993d32 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,10 +51,6 @@ 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,12 +90,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { 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 d717803108..524789a51a 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -63,10 +63,6 @@ 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,12 +102,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index dbda232f59..860d249ee0 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -43,10 +43,6 @@ 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,12 +82,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js index c0ae2a8ba0..96d3b06cc8 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -43,10 +43,6 @@ 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,12 +82,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { 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 31d618922e..29e8a05a8b 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -47,10 +47,6 @@ 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,12 +86,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index f36462efad..80a2a1475c 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -47,10 +47,6 @@ 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,12 +86,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { 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 57402a155a..4348f9367e 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -47,10 +47,6 @@ 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,12 +86,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { 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 069cc003b7..017dc960fc 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -47,10 +47,6 @@ 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,12 +86,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js index 643017655d..fc1ba783cc 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -47,10 +47,6 @@ 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,12 +86,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js index 906bf21bb5..3958d3862b 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -47,10 +47,6 @@ 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,12 +86,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { 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 a02405f10a..dbed2a12c0 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -51,10 +51,6 @@ 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,12 +90,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index b54727a24c..5b49b4995a 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -49,10 +49,6 @@ 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,12 +88,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/legacy-quote-class/expected-bundle.js b/test/js/samples/legacy-quote-class/expected-bundle.js index 3177f32f16..db13a962c9 100644 --- a/test/js/samples/legacy-quote-class/expected-bundle.js +++ b/test/js/samples/legacy-quote-class/expected-bundle.js @@ -66,10 +66,6 @@ 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,12 +105,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index 7a258f8965..230454d955 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -59,10 +59,6 @@ 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,12 +98,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 2799a85ebe..b037ff3ad4 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -45,10 +45,6 @@ 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,12 +84,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index 049ba0d86a..c0d41a7c76 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -31,10 +31,6 @@ 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,12 +70,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 388bb495bc..d1b04e43a5 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -31,10 +31,6 @@ 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,12 +70,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index 46880a584c..21f8467d3b 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -51,10 +51,6 @@ 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,12 +90,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index 4e70625f70..bebf5e4466 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -31,10 +31,6 @@ 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,12 +70,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { 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 2045954b41..f7302d8bd7 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -55,10 +55,6 @@ 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,12 +94,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) { diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index b0014988b7..f522e5f96d 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -51,10 +51,6 @@ 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,12 +90,11 @@ function init(component, options) { component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); component._bind = options._bind; + component._differs = differs; 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) {