From c2f0ca3e2e43e635d1ff2b33349b50ffb3c54c19 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 25 Aug 2018 06:58:31 -0400 Subject: [PATCH] alternative approach to #1520 --- src/compile/dom/index.ts | 2 +- src/shared/index.js | 27 ++++++------- store.js | 38 +++++++++---------- test/cli/samples/amd/expected/Main.js | 26 ++++++------- test/cli/samples/basic/expected/Main.js | 26 ++++++------- .../samples/custom-element/expected/Main.js | 26 ++++++------- test/cli/samples/dev/expected/Main.js | 26 ++++++------- .../samples/dir-sourcemap/expected/Main.js | 26 ++++++------- .../dir-sourcemap/expected/Main.js.map | 2 +- .../samples/dir-sourcemap/expected/Widget.js | 26 ++++++------- .../dir-sourcemap/expected/Widget.js.map | 2 +- test/cli/samples/dir-subdir/expected/Main.js | 26 ++++++------- .../dir-subdir/expected/widget/Widget.js | 26 ++++++------- test/cli/samples/dir/expected/Main.js | 26 ++++++------- test/cli/samples/dir/expected/Widget.js | 26 ++++++------- test/cli/samples/globals/expected/Main.js | 28 ++++++-------- .../samples/sourcemap-inline/expected/Main.js | 30 +++++++-------- test/cli/samples/sourcemap/expected/Main.js | 26 ++++++------- .../samples/sourcemap/expected/Main.js.map | 2 +- test/cli/samples/store/expected/Main.js | 26 ++++++------- test/js/samples/action/expected-bundle.js | 28 ++++++-------- test/js/samples/action/expected.js | 2 +- .../bind-width-height/expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../component-static-array/expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../component-static/expected-bundle.js | 26 ++++++------- .../computed-collapsed-if/expected-bundle.js | 26 ++++++------- .../css-media-query/expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../js/samples/debug-empty/expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- test/js/samples/debug-foo/expected-bundle.js | 26 ++++++------- .../deconflict-builtins/expected-bundle.js | 26 ++++++------- .../deconflict-globals/expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../samples/do-use-dataset/expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../each-block-keyed/expected-bundle.js | 26 ++++++------- .../event-handlers-custom/expected-bundle.js | 26 ++++++------- .../head-no-whitespace/expected-bundle.js | 26 ++++++------- .../if-block-no-update/expected-bundle.js | 26 ++++++------- .../if-block-simple/expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../inline-style-optimized/expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../js/samples/input-files/expected-bundle.js | 26 ++++++------- .../js/samples/input-range/expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../legacy-input-type/expected-bundle.js | 26 ++++++------- .../samples/media-bindings/expected-bundle.js | 26 ++++++------- .../non-imported-component/expected-bundle.js | 26 ++++++------- .../select-dynamic-value/expected-bundle.js | 10 +++++ .../samples/setup-method/expected-bundle.js | 26 ++++++------- test/js/samples/svg-title/expected-bundle.js | 26 ++++++------- test/js/samples/title/expected-bundle.js | 26 ++++++------- .../expected-bundle.js | 26 ++++++------- .../window-binding-scroll/expected-bundle.js | 26 ++++++------- 63 files changed, 655 insertions(+), 868 deletions(-) diff --git a/src/compile/dom/index.ts b/src/compile/dom/index.ts index 79645f4081..3ced0254a2 100644 --- a/src/compile/dom/index.ts +++ b/src/compile/dom/index.ts @@ -132,7 +132,7 @@ export default function dom( ? `@proto` : deindent` { - ${['destroy', 'get', 'fire', 'on', 'set', '_set', '_mount', '_differs'] + ${['destroy', 'get', 'fire', 'on', 'set', '_set', '_stage', '_mount', '_differs'] .map(n => `${n}: @${n}`) .join(',\n')} }`; diff --git a/src/shared/index.js b/src/shared/index.js index f2621472fd..f178bdfba7 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -73,6 +73,7 @@ export function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -103,30 +104,21 @@ export function set(newState) { flush(this.root); } -export function _set(newState, options) { +export function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -135,7 +127,10 @@ export function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +export function _stage(newState) { + assign(this._staged, newState); } export function setDev(newState) { @@ -173,6 +168,7 @@ export var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; @@ -185,6 +181,7 @@ export var protoDev = { set: setDev, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/store.js b/store.js index cc97eddb8a..ad7db26194 100644 --- a/store.js +++ b/store.js @@ -60,27 +60,27 @@ assign(Store.prototype, { current: this._state }); - const dependents = this._dependents.slice(); // guard against mutations - const options = { skipRender: true }; - const empty = {}; - const dirtyDependents = dependents.filter(dependent => { - const componentState = {}; - let dirty = false; - - for (let j = 0; j < dependent.props.length; j += 1) { - const prop = dependent.props[j]; - if (prop in changed) { - componentState['$' + prop] = this._state[prop]; - dirty = true; + this._dependents + .filter(dependent => { + const componentState = {}; + let dirty = false; + + for (let j = 0; j < dependent.props.length; j += 1) { + const prop = dependent.props[j]; + if (prop in changed) { + componentState['$' + prop] = this._state[prop]; + dirty = true; + } } - } - if (dirty) { - return dependent.component._set(componentState, options); - } - }); - - dirtyDependents.forEach(dependent => dependent.component.set(empty)); + if (dirty) { + dependent.component._stage(componentState); + return true; + } + }) + .forEach(dependent => { + dependent.component.set(); + }); this.fire('update', { changed, diff --git a/test/cli/samples/amd/expected/Main.js b/test/cli/samples/amd/expected/Main.js index bbdc8c40de..e1d5ff49de 100644 --- a/test/cli/samples/amd/expected/Main.js +++ b/test/cli/samples/amd/expected/Main.js @@ -43,6 +43,7 @@ define("test", function() { "use strict"; on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -67,6 +68,7 @@ define("test", function() { "use strict"; component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -135,30 +137,21 @@ define("test", function() { "use strict"; flush(this.root); } - function _set(newState, options) { + function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -167,7 +160,10 @@ define("test", function() { "use strict"; this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; + } + + function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/basic/expected/Main.js b/test/cli/samples/basic/expected/Main.js index a2184f1082..33a814b893 100644 --- a/test/cli/samples/basic/expected/Main.js +++ b/test/cli/samples/basic/expected/Main.js @@ -43,6 +43,7 @@ assign(Main.prototype, { on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -67,6 +68,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -135,30 +137,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -167,7 +160,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/custom-element/expected/Main.js b/test/cli/samples/custom-element/expected/Main.js index dc26df5ccb..e3b62932bd 100644 --- a/test/cli/samples/custom-element/expected/Main.js +++ b/test/cli/samples/custom-element/expected/Main.js @@ -57,6 +57,7 @@ assign(Main.prototype, { on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -88,6 +89,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -156,30 +158,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -188,7 +181,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/dev/expected/Main.js b/test/cli/samples/dev/expected/Main.js index 02c90d3ec6..bc00172d44 100644 --- a/test/cli/samples/dev/expected/Main.js +++ b/test/cli/samples/dev/expected/Main.js @@ -50,6 +50,7 @@ assign(Main.prototype, { on: on, set: setDev, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -91,6 +92,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -161,30 +163,21 @@ function setDev(newState) { set.call(this, newState); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -193,7 +186,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js b/test/cli/samples/dir-sourcemap/expected/Main.js index 9d0f26df36..17b9ea2969 100644 --- a/test/cli/samples/dir-sourcemap/expected/Main.js +++ b/test/cli/samples/dir-sourcemap/expected/Main.js @@ -49,6 +49,7 @@ assign(Main.prototype, { on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -61,6 +62,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -137,30 +139,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -169,7 +162,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js.map b/test/cli/samples/dir-sourcemap/expected/Main.js.map index 78e23900d6..99bf481039 100644 --- a/test/cli/samples/dir-sourcemap/expected/Main.js.map +++ b/test/cli/samples/dir-sourcemap/expected/Main.js.map @@ -1 +1 @@ -{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} +{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/cli/samples/dir-sourcemap/expected/Widget.js b/test/cli/samples/dir-sourcemap/expected/Widget.js index d671a74fa4..b4ae7743d5 100644 --- a/test/cli/samples/dir-sourcemap/expected/Widget.js +++ b/test/cli/samples/dir-sourcemap/expected/Widget.js @@ -43,6 +43,7 @@ assign(Widget.prototype, { on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -67,6 +68,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -135,30 +137,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -167,7 +160,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/dir-sourcemap/expected/Widget.js.map b/test/cli/samples/dir-sourcemap/expected/Widget.js.map index 0751cc8243..dbfc4c78f6 100644 --- a/test/cli/samples/dir-sourcemap/expected/Widget.js.map +++ b/test/cli/samples/dir-sourcemap/expected/Widget.js.map @@ -1 +1 @@ -{"version":3,"file":"Widget.js","sources":["../src/Widget.html"],"sourcesContent":["

widget

"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} +{"version":3,"file":"Widget.js","sources":["../src/Widget.html"],"sourcesContent":["

widget

"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/cli/samples/dir-subdir/expected/Main.js b/test/cli/samples/dir-subdir/expected/Main.js index d55ad9252d..48f0596e3c 100644 --- a/test/cli/samples/dir-subdir/expected/Main.js +++ b/test/cli/samples/dir-subdir/expected/Main.js @@ -49,6 +49,7 @@ assign(Main.prototype, { on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -61,6 +62,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -137,30 +139,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -169,7 +162,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/dir-subdir/expected/widget/Widget.js b/test/cli/samples/dir-subdir/expected/widget/Widget.js index 85acf3362d..08858aee63 100644 --- a/test/cli/samples/dir-subdir/expected/widget/Widget.js +++ b/test/cli/samples/dir-subdir/expected/widget/Widget.js @@ -43,6 +43,7 @@ assign(Widget.prototype, { on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -67,6 +68,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -135,30 +137,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -167,7 +160,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/dir/expected/Main.js b/test/cli/samples/dir/expected/Main.js index db8e37a299..24da010131 100644 --- a/test/cli/samples/dir/expected/Main.js +++ b/test/cli/samples/dir/expected/Main.js @@ -49,6 +49,7 @@ assign(Main.prototype, { on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -61,6 +62,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -137,30 +139,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -169,7 +162,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/dir/expected/Widget.js b/test/cli/samples/dir/expected/Widget.js index 3272585b10..3e5a538fc1 100644 --- a/test/cli/samples/dir/expected/Widget.js +++ b/test/cli/samples/dir/expected/Widget.js @@ -43,6 +43,7 @@ assign(Widget.prototype, { on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -67,6 +68,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -135,30 +137,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -167,7 +160,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/globals/expected/Main.js b/test/cli/samples/globals/expected/Main.js index 23d60a76da..c578cbf2e3 100644 --- a/test/cli/samples/globals/expected/Main.js +++ b/test/cli/samples/globals/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.11.0 */ +/* src/Main.html generated by Svelte vx.y.z */ var Main = (function(answer) { "use strict"; answer = (answer && answer.__esModule) ? answer["default"] : answer; @@ -58,6 +58,7 @@ var Main = (function(answer) { "use strict"; on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -92,6 +93,7 @@ var Main = (function(answer) { "use strict"; component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -160,30 +162,21 @@ var Main = (function(answer) { "use strict"; flush(this.root); } - function _set(newState, options) { + function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -192,7 +185,10 @@ var Main = (function(answer) { "use strict"; this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; + } + + function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/sourcemap-inline/expected/Main.js b/test/cli/samples/sourcemap-inline/expected/Main.js index 41bcb21adf..7ecedd8afc 100644 --- a/test/cli/samples/sourcemap-inline/expected/Main.js +++ b/test/cli/samples/sourcemap-inline/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.12.0 */ +/* src/Main.html generated by Svelte vx.y.z */ function create_main_fragment(component, ctx) { var p; @@ -43,6 +43,7 @@ assign(Main.prototype, { on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -67,6 +68,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -135,30 +137,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -167,7 +160,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { @@ -194,4 +190,4 @@ function callAll(fns) { while (fns && fns.length) fns.shift()(); } export default Main; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ== +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9 diff --git a/test/cli/samples/sourcemap/expected/Main.js b/test/cli/samples/sourcemap/expected/Main.js index 4aa6a89a33..8f8e38c84d 100644 --- a/test/cli/samples/sourcemap/expected/Main.js +++ b/test/cli/samples/sourcemap/expected/Main.js @@ -43,6 +43,7 @@ assign(Main.prototype, { on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -67,6 +68,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -135,30 +137,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -167,7 +160,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/cli/samples/sourcemap/expected/Main.js.map b/test/cli/samples/sourcemap/expected/Main.js.map index ddf03feb32..c95bf0cb91 100644 --- a/test/cli/samples/sourcemap/expected/Main.js.map +++ b/test/cli/samples/sourcemap/expected/Main.js.map @@ -1 +1 @@ -{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["

Hello world!

\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} +{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["

Hello world!

\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/cli/samples/store/expected/Main.js b/test/cli/samples/store/expected/Main.js index 7dbef5e6bd..699ecb434e 100644 --- a/test/cli/samples/store/expected/Main.js +++ b/test/cli/samples/store/expected/Main.js @@ -53,6 +53,7 @@ assign(Main.prototype, { on: on, set: set, _set: _set, + _stage: _stage, _mount: _mount, _differs: _differs }); @@ -87,6 +88,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -159,30 +161,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -191,7 +184,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function _mount(target, anchor) { diff --git a/test/js/samples/action/expected-bundle.js b/test/js/samples/action/expected-bundle.js index bc43dc005e..b05b0a36f4 100644 --- a/test/js/samples/action/expected-bundle.js +++ b/test/js/samples/action/expected-bundle.js @@ -70,6 +70,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -100,30 +101,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -132,7 +124,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -151,6 +146,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; @@ -158,7 +154,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ function link(node) { - + function onClick(event) { event.preventDefault(); history.pushState(null, null, event.target.href); diff --git a/test/js/samples/action/expected.js b/test/js/samples/action/expected.js index fab6e6a2b6..2c173d0133 100644 --- a/test/js/samples/action/expected.js +++ b/test/js/samples/action/expected.js @@ -2,7 +2,7 @@ import { assign, createElement, detachNode, init, insert, noop, proto } from "svelte/shared.js"; function link(node) { - + function onClick(event) { event.preventDefault(); history.pushState(null, null, event.target.href); diff --git a/test/js/samples/bind-width-height/expected-bundle.js b/test/js/samples/bind-width-height/expected-bundle.js index 03fe95e231..0e39cd0082 100644 --- a/test/js/samples/bind-width-height/expected-bundle.js +++ b/test/js/samples/bind-width-height/expected-bundle.js @@ -102,6 +102,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -132,30 +133,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -164,7 +156,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -183,6 +178,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; 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 54404a90e0..4237251ca5 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -82,6 +82,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -112,30 +113,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -144,7 +136,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -163,6 +158,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/component-static-array/expected-bundle.js b/test/js/samples/component-static-array/expected-bundle.js index e79f5517c0..730f5fe08d 100644 --- a/test/js/samples/component-static-array/expected-bundle.js +++ b/test/js/samples/component-static-array/expected-bundle.js @@ -58,6 +58,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -88,30 +89,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -120,7 +112,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -139,6 +134,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js index de9b07fd4b..7a1eae18bd 100644 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -62,6 +62,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -92,30 +93,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -124,7 +116,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -143,6 +138,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js index de9b07fd4b..7a1eae18bd 100644 --- a/test/js/samples/component-static-immutable2/expected-bundle.js +++ b/test/js/samples/component-static-immutable2/expected-bundle.js @@ -62,6 +62,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -92,30 +93,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -124,7 +116,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -143,6 +138,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index 11d8560a12..8894cef94a 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -58,6 +58,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -88,30 +89,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -120,7 +112,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -139,6 +134,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index f26f7d4a5c..54fbb17dfe 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -58,6 +58,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -88,30 +89,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -120,7 +112,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -139,6 +134,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index 38eb1515e2..f5d45282c7 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -74,6 +74,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -104,30 +105,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -136,7 +128,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -155,6 +150,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; 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 59a4d81b09..c31dc80868 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -70,6 +70,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -100,30 +101,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -132,7 +124,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -151,6 +146,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/debug-empty/expected-bundle.js b/test/js/samples/debug-empty/expected-bundle.js index 3ec5c1033b..836da9ec13 100644 --- a/test/js/samples/debug-empty/expected-bundle.js +++ b/test/js/samples/debug-empty/expected-bundle.js @@ -95,6 +95,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -125,30 +126,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -157,7 +149,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function setDev(newState) { @@ -187,6 +182,7 @@ var protoDev = { set: setDev, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/debug-foo-bar-baz-things/expected-bundle.js b/test/js/samples/debug-foo-bar-baz-things/expected-bundle.js index 82e6fb7635..e065526f46 100644 --- a/test/js/samples/debug-foo-bar-baz-things/expected-bundle.js +++ b/test/js/samples/debug-foo-bar-baz-things/expected-bundle.js @@ -101,6 +101,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -131,30 +132,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -163,7 +155,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function setDev(newState) { @@ -193,6 +188,7 @@ var protoDev = { set: setDev, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/debug-foo/expected-bundle.js b/test/js/samples/debug-foo/expected-bundle.js index a7e2c0611f..9f63d821c1 100644 --- a/test/js/samples/debug-foo/expected-bundle.js +++ b/test/js/samples/debug-foo/expected-bundle.js @@ -101,6 +101,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -131,30 +132,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -163,7 +155,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function setDev(newState) { @@ -193,6 +188,7 @@ var protoDev = { set: setDev, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js index 8c4abeae16..2ca3005a6d 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ b/test/js/samples/deconflict-builtins/expected-bundle.js @@ -92,6 +92,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -122,30 +123,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -154,7 +146,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -173,6 +168,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index b698bbe466..264d4f2997 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -63,6 +63,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -93,30 +94,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -125,7 +117,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -144,6 +139,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js index 7ca4a2846e..f389d5b61f 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js @@ -95,6 +95,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -125,30 +126,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -157,7 +149,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function setDev(newState) { @@ -187,6 +182,7 @@ var protoDev = { set: setDev, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js index b4f9e22f08..3999854ba2 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -74,6 +74,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -104,30 +105,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -136,7 +128,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -155,6 +150,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; 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 a507c84c56..bb07f5b2ec 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 @@ -78,6 +78,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -108,30 +109,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -140,7 +132,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -159,6 +154,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; 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 918f28b238..72320b8787 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 @@ -78,6 +78,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -108,30 +109,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -140,7 +132,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -159,6 +154,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; 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 bd3eb27347..cf589ed35f 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -94,6 +94,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -124,30 +125,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -156,7 +148,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -175,6 +170,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/each-block-keyed-animated/expected-bundle.js b/test/js/samples/each-block-keyed-animated/expected-bundle.js index 2417c27cc7..a77947e64f 100644 --- a/test/js/samples/each-block-keyed-animated/expected-bundle.js +++ b/test/js/samples/each-block-keyed-animated/expected-bundle.js @@ -397,6 +397,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -427,30 +428,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -459,7 +451,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -478,6 +473,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/each-block-keyed/expected-bundle.js b/test/js/samples/each-block-keyed/expected-bundle.js index 5328875aec..d316cc59e2 100644 --- a/test/js/samples/each-block-keyed/expected-bundle.js +++ b/test/js/samples/each-block-keyed/expected-bundle.js @@ -177,6 +177,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -207,30 +208,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -239,7 +231,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -258,6 +253,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 84710c2a5f..91e25f29b0 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -70,6 +70,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -100,30 +101,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -132,7 +124,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -151,6 +146,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js index b5c252e0e8..d753546f73 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -70,6 +70,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -100,30 +101,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -132,7 +124,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -151,6 +146,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; 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 3337ed46a4..35359986d5 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -74,6 +74,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -104,30 +105,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -136,7 +128,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -155,6 +150,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index df0d5c6090..346da11fe1 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -74,6 +74,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -104,30 +105,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -136,7 +128,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -155,6 +150,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; 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 2a7972f168..e63af6741b 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -74,6 +74,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -104,30 +105,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -136,7 +128,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -155,6 +150,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; 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 b2167b0699..0df847bbef 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -74,6 +74,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -104,30 +105,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -136,7 +128,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -155,6 +150,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js index 58ecf9a44f..eb45ed55f6 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -74,6 +74,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -104,30 +105,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -136,7 +128,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -155,6 +150,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js index dcfcc87505..a8e204eb17 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -74,6 +74,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -104,30 +105,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -136,7 +128,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -155,6 +150,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/input-files/expected-bundle.js b/test/js/samples/input-files/expected-bundle.js index 6eee764362..7c3c064c14 100644 --- a/test/js/samples/input-files/expected-bundle.js +++ b/test/js/samples/input-files/expected-bundle.js @@ -82,6 +82,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -112,30 +113,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -144,7 +136,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -163,6 +158,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/input-range/expected-bundle.js b/test/js/samples/input-range/expected-bundle.js index 61db6b93b3..f9cde9c06d 100644 --- a/test/js/samples/input-range/expected-bundle.js +++ b/test/js/samples/input-range/expected-bundle.js @@ -86,6 +86,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -116,30 +117,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -148,7 +140,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -167,6 +162,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; 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 8d644c98b2..55c7819baf 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -82,6 +82,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -112,30 +113,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -144,7 +136,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -163,6 +158,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index a4e2df868a..2b0ce9b3b8 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -76,6 +76,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -106,30 +107,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -138,7 +130,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -157,6 +152,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index 419aa83410..c61a74d5ae 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -86,6 +86,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -116,30 +117,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -148,7 +140,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -167,6 +162,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 6923d44238..a230bdf762 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -72,6 +72,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -102,30 +103,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -134,7 +126,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -153,6 +148,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/select-dynamic-value/expected-bundle.js b/test/js/samples/select-dynamic-value/expected-bundle.js index 1230856164..56fa22a859 100644 --- a/test/js/samples/select-dynamic-value/expected-bundle.js +++ b/test/js/samples/select-dynamic-value/expected-bundle.js @@ -78,6 +78,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -113,12 +114,16 @@ function _set(newState) { changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } if (!dirty) return; this._state = assign(assign({}, oldState), newState); + this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -129,6 +134,10 @@ function _set(newState) { } } +function _stage(newState) { + assign(this._staged, newState); +} + function callAll(fns) { while (fns && fns.length) fns.shift()(); } @@ -145,6 +154,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 71b3bcb2da..a059ea0abb 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -58,6 +58,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -88,30 +89,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -120,7 +112,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -139,6 +134,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index 0ac2e61941..293be218e3 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -78,6 +78,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -108,30 +109,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -140,7 +132,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -159,6 +154,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index afcd2da045..85e0254f0f 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -58,6 +58,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -88,30 +89,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -120,7 +112,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -139,6 +134,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; 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 b0c26ffdaa..dff42ca138 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -82,6 +82,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -112,30 +113,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -144,7 +136,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -163,6 +158,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs }; diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index 315a13e5f9..774f5eedf0 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -82,6 +82,7 @@ function init(component, options) { component._handlers = blankObject(); component._slots = blankObject(); component._bind = options._bind; + component._staged = {}; component.options = options; component.root = options.root || component; @@ -112,30 +113,21 @@ function set(newState) { flush(this.root); } -function _set(newState, options) { +function _set(newState) { var oldState = this._state, changed = {}, dirty = false; + newState = assign(this._staged, newState); + this._staged = {}; + for (var key in newState) { if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; } - if (!dirty && !this._changed) return false; + if (!dirty) return; this._state = assign(assign({}, oldState), newState); - if (options && options.skipRender) { - if (!this._oldState) this._oldState = oldState; - this._changed = assign(changed, this._changed); - return true; - } - - if (this._changed) { - oldState = this._oldState; - changed = assign(changed, this._changed), - this._changed = this._oldState = null; - } - this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); @@ -144,7 +136,10 @@ function _set(newState, options) { this._fragment.p(changed, this._state); this.fire("update", { changed: changed, current: this._state, previous: oldState }); } - return true; +} + +function _stage(newState) { + assign(this._staged, newState); } function callAll(fns) { @@ -163,6 +158,7 @@ var proto = { set, _recompute: noop, _set, + _stage, _mount, _differs };