diff --git a/src/compile/dom/index.ts b/src/compile/dom/index.ts
index 13e709b04f4b..79645f408152 100644
--- a/src/compile/dom/index.ts
+++ b/src/compile/dom/index.ts
@@ -212,16 +212,6 @@ export default function dom(
`if (!document.getElementById("${compiler.stylesheet.id}-style")) @add_css();`)
}
- ${(hasInitHooks || compiler.hasComponents || target.hasComplexBindings || target.hasIntroTransitions) && deindent`
- if (!options.root) {
- this._oncreate = [];
- ${(compiler.hasComponents || target.hasComplexBindings) && `this._beforecreate = [];`}
- ${(compiler.hasComponents || target.hasIntroTransitions) && `this._aftercreate = [];`}
- }
- `}
-
- ${compiler.slots.size && `this.slots = {};`}
-
${templateProperties.onstate && `%onstate.call(this, { changed: @assignTrue({}, this._state), current: this._state });`}
this._fragment = @create_main_fragment(this, this._state);
@@ -241,24 +231,18 @@ export default function dom(
` : deindent`
if (options.target) {
${compiler.options.hydratable
- ? deindent`
- var nodes = @children(options.target);
- options.hydrate ? this._fragment.l(nodes) : this._fragment.c();
- nodes.forEach(@detachNode);
- ` :
- deindent`
- ${options.dev && `if (options.hydrate) throw new Error("options.hydrate only works if the component was compiled with the \`hydratable: true\` option");`}
- this._fragment.c();
- `}
+ ? deindent`
+ var nodes = @children(options.target);
+ options.hydrate ? this._fragment.l(nodes) : this._fragment.c();
+ nodes.forEach(@detachNode);` :
+ deindent`
+ ${options.dev &&
+ `if (options.hydrate) throw new Error("options.hydrate only works if the component was compiled with the \`hydratable: true\` option");`}
+ this._fragment.c();`}
this._mount(options.target, options.anchor);
- ${(compiler.hasComponents || target.hasComplexBindings || hasInitHooks || target.hasIntroTransitions) && deindent`
- ${compiler.hasComponents && `this._lock = true;`}
- ${(compiler.hasComponents || target.hasComplexBindings) && `@callAll(this._beforecreate);`}
- ${(compiler.hasComponents || hasInitHooks) && `@callAll(this._oncreate);`}
- ${(compiler.hasComponents || target.hasIntroTransitions) && `@callAll(this._aftercreate);`}
- ${compiler.hasComponents && `this._lock = false;`}
- `}
+ ${(compiler.hasComponents || target.hasComplexBindings || hasInitHooks || target.hasIntroTransitions) &&
+ `@flush(this);`}
}
`}
@@ -302,11 +286,7 @@ export default function dom(
${(compiler.hasComponents || target.hasComplexBindings || templateProperties.oncreate || target.hasIntroTransitions) && deindent`
connectedCallback() {
- ${compiler.hasComponents && `this._lock = true;`}
- ${(compiler.hasComponents || target.hasComplexBindings) && `@callAll(this._beforecreate);`}
- ${(compiler.hasComponents || templateProperties.oncreate) && `@callAll(this._oncreate);`}
- ${(compiler.hasComponents || target.hasIntroTransitions) && `@callAll(this._aftercreate);`}
- ${compiler.hasComponents && `this._lock = false;`}
+ @flush(this);
}
`}
}
diff --git a/src/shared/index.js b/src/shared/index.js
index e4c71046e36e..47e7a75099d5 100644
--- a/src/shared/index.js
+++ b/src/shared/index.js
@@ -57,17 +57,32 @@ export function fire(eventName, data) {
}
}
+export function flush(component) {
+ component._lock = true;
+ callAll(component._beforecreate);
+ callAll(component._oncreate);
+ callAll(component._aftercreate);
+ component._lock = false;
+}
+
export function get() {
return this._state;
}
export function init(component, options) {
component._handlers = blankObject();
+ component._slots = blankObject();
component._bind = options._bind;
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
+
+ if (!options.root) {
+ component._beforecreate = [];
+ component._oncreate = [];
+ component._aftercreate = [];
+ }
}
export function on(eventName, handler) {
@@ -89,11 +104,7 @@ export function run(fn) {
export function set(newState) {
this._set(assign({}, newState));
if (this.root._lock) return;
- this.root._lock = true;
- callAll(this.root._beforecreate);
- callAll(this.root._oncreate);
- callAll(this.root._aftercreate);
- this.root._lock = false;
+ flush(this.root);
}
export function _set(newState) {
diff --git a/test/cli/samples/basic/expected/Main.js b/test/cli/samples/basic/expected/Main.js
index 67af2d675aca..7d24fd3862e0 100644
--- a/test/cli/samples/basic/expected/Main.js
+++ b/test/cli/samples/basic/expected/Main.js
@@ -65,11 +65,18 @@ function detachNode(node) {
function init(component, options) {
component._handlers = blankObject();
+ component._slots = blankObject();
component._bind = options._bind;
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
+
+ if (!options.root) {
+ component._beforecreate = [];
+ component._oncreate = [];
+ component._aftercreate = [];
+ }
}
function assign(tar, src) {
@@ -125,11 +132,7 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
if (this.root._lock) return;
- this.root._lock = true;
- callAll(this.root._beforecreate);
- callAll(this.root._oncreate);
- callAll(this.root._aftercreate);
- this.root._lock = false;
+ flush(this.root);
}
function _set(newState) {
@@ -165,6 +168,14 @@ function blankObject() {
return Object.create(null);
}
+function flush(component) {
+ component._lock = true;
+ callAll(component._beforecreate);
+ callAll(component._oncreate);
+ callAll(component._aftercreate);
+ component._lock = false;
+}
+
function callAll(fns) {
while (fns && fns.length) fns.shift()();
}
diff --git a/test/cli/samples/custom-element/expected/Main.js b/test/cli/samples/custom-element/expected/Main.js
index 0a72476e01c3..1d34cc12a6dd 100644
--- a/test/cli/samples/custom-element/expected/Main.js
+++ b/test/cli/samples/custom-element/expected/Main.js
@@ -86,11 +86,18 @@ function detachNode(node) {
function init(component, options) {
component._handlers = blankObject();
+ component._slots = blankObject();
component._bind = options._bind;
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
+
+ if (!options.root) {
+ component._beforecreate = [];
+ component._oncreate = [];
+ component._aftercreate = [];
+ }
}
function assign(tar, src) {
@@ -146,11 +153,7 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
if (this.root._lock) return;
- this.root._lock = true;
- callAll(this.root._beforecreate);
- callAll(this.root._oncreate);
- callAll(this.root._aftercreate);
- this.root._lock = false;
+ flush(this.root);
}
function _set(newState) {
@@ -186,6 +189,14 @@ function blankObject() {
return Object.create(null);
}
+function flush(component) {
+ component._lock = true;
+ callAll(component._beforecreate);
+ callAll(component._oncreate);
+ callAll(component._aftercreate);
+ component._lock = false;
+}
+
function callAll(fns) {
while (fns && fns.length) fns.shift()();
}
diff --git a/test/cli/samples/dev/expected/Main.js b/test/cli/samples/dev/expected/Main.js
index d342cfb2db11..e32ea9a61efc 100644
--- a/test/cli/samples/dev/expected/Main.js
+++ b/test/cli/samples/dev/expected/Main.js
@@ -89,11 +89,18 @@ function detachNode(node) {
function init(component, options) {
component._handlers = blankObject();
+ component._slots = blankObject();
component._bind = options._bind;
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
+
+ if (!options.root) {
+ component._beforecreate = [];
+ component._oncreate = [];
+ component._aftercreate = [];
+ }
}
function assign(tar, src) {
@@ -200,11 +207,15 @@ function destroy(detach) {
function set(newState) {
this._set(assign({}, newState));
if (this.root._lock) return;
- this.root._lock = true;
- callAll(this.root._beforecreate);
- callAll(this.root._oncreate);
- callAll(this.root._aftercreate);
- this.root._lock = false;
+ flush(this.root);
+}
+
+function flush(component) {
+ component._lock = true;
+ callAll(component._beforecreate);
+ callAll(component._oncreate);
+ callAll(component._aftercreate);
+ component._lock = false;
}
function callAll(fns) {
diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js b/test/cli/samples/dir-sourcemap/expected/Main.js
index 31c1929c53ed..884f11d1d3d0 100644
--- a/test/cli/samples/dir-sourcemap/expected/Main.js
+++ b/test/cli/samples/dir-sourcemap/expected/Main.js
@@ -32,23 +32,13 @@ function Main(options) {
this._state = assign({}, options.data);
this._intro = true;
- if (!options.root) {
- this._oncreate = [];
- this._beforecreate = [];
- this._aftercreate = [];
- }
-
this._fragment = create_main_fragment(this, this._state);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
- this._lock = true;
- callAll(this._beforecreate);
- callAll(this._oncreate);
- callAll(this._aftercreate);
- this._lock = false;
+ flush(this);
}
}
@@ -69,11 +59,18 @@ function noop() {}
function init(component, options) {
component._handlers = blankObject();
+ component._slots = blankObject();
component._bind = options._bind;
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
+
+ if (!options.root) {
+ component._beforecreate = [];
+ component._oncreate = [];
+ component._aftercreate = [];
+ }
}
function assign(tar, src) {
@@ -81,8 +78,12 @@ function assign(tar, src) {
return tar;
}
-function callAll(fns) {
- while (fns && fns.length) fns.shift()();
+function flush(component) {
+ component._lock = true;
+ callAll(component._beforecreate);
+ callAll(component._oncreate);
+ callAll(component._aftercreate);
+ component._lock = false;
}
function destroy(detach) {
@@ -133,11 +134,7 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
if (this.root._lock) return;
- this.root._lock = true;
- callAll(this.root._beforecreate);
- callAll(this.root._oncreate);
- callAll(this.root._aftercreate);
- this.root._lock = false;
+ flush(this.root);
}
function _set(newState) {
@@ -172,5 +169,9 @@ function _differs(a, b) {
function blankObject() {
return Object.create(null);
}
+
+function callAll(fns) {
+ while (fns && fns.length) fns.shift()();
+}
export default Main;
//# sourceMappingURL=Main.js.map
diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js.map b/test/cli/samples/dir-sourcemap/expected/Main.js.map
index 7c0c800ddb62..1d09d8ade9fe 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":["
widget
"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"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 2e908cfa44b1..4b1803f5fc3c 100644 --- a/test/cli/samples/dir-subdir/expected/Main.js +++ b/test/cli/samples/dir-subdir/expected/Main.js @@ -32,23 +32,13 @@ function Main(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } @@ -69,11 +59,18 @@ function noop() {} function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function assign(tar, src) { @@ -81,8 +78,12 @@ function assign(tar, src) { return tar; } -function callAll(fns) { - while (fns && fns.length) fns.shift()(); +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; } function destroy(detach) { @@ -133,11 +134,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -172,4 +169,8 @@ function _differs(a, b) { function blankObject() { return Object.create(null); } + +function callAll(fns) { + while (fns && fns.length) fns.shift()(); +} export default Main; \ No newline at end of file diff --git a/test/cli/samples/dir-subdir/expected/widget/Widget.js b/test/cli/samples/dir-subdir/expected/widget/Widget.js index e368f4d9b628..5c6241e3208a 100644 --- a/test/cli/samples/dir-subdir/expected/widget/Widget.js +++ b/test/cli/samples/dir-subdir/expected/widget/Widget.js @@ -65,11 +65,18 @@ function detachNode(node) { function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function assign(tar, src) { @@ -125,11 +132,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -165,6 +168,14 @@ function blankObject() { return Object.create(null); } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function callAll(fns) { while (fns && fns.length) fns.shift()(); } diff --git a/test/cli/samples/dir/expected/Main.js b/test/cli/samples/dir/expected/Main.js index 9a9d8e38fe64..dc82848d2e7b 100644 --- a/test/cli/samples/dir/expected/Main.js +++ b/test/cli/samples/dir/expected/Main.js @@ -32,23 +32,13 @@ function Main(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } @@ -69,11 +59,18 @@ function noop() {} function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function assign(tar, src) { @@ -81,8 +78,12 @@ function assign(tar, src) { return tar; } -function callAll(fns) { - while (fns && fns.length) fns.shift()(); +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; } function destroy(detach) { @@ -133,11 +134,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -172,4 +169,8 @@ function _differs(a, b) { function blankObject() { return Object.create(null); } + +function callAll(fns) { + while (fns && fns.length) fns.shift()(); +} export default Main; \ No newline at end of file diff --git a/test/cli/samples/dir/expected/Widget.js b/test/cli/samples/dir/expected/Widget.js index 91d975a48fba..2896558acc07 100644 --- a/test/cli/samples/dir/expected/Widget.js +++ b/test/cli/samples/dir/expected/Widget.js @@ -65,11 +65,18 @@ function detachNode(node) { function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function assign(tar, src) { @@ -125,11 +132,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -165,6 +168,14 @@ function blankObject() { return Object.create(null); } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function callAll(fns) { while (fns && fns.length) fns.shift()(); } diff --git a/test/cli/samples/globals/expected/Main.js b/test/cli/samples/globals/expected/Main.js index 5f5b5093f419..62d5a0269449 100644 --- a/test/cli/samples/globals/expected/Main.js +++ b/test/cli/samples/globals/expected/Main.js @@ -90,11 +90,18 @@ var Main = (function(answer) { "use strict"; function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function assign(tar, src) { @@ -150,11 +157,7 @@ var Main = (function(answer) { "use strict"; function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -192,6 +195,14 @@ var Main = (function(answer) { "use strict"; return Object.create(null); } + function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; + } + function callAll(fns) { while (fns && fns.length) fns.shift()(); } diff --git a/test/cli/samples/sourcemap-inline/expected/Main.js b/test/cli/samples/sourcemap-inline/expected/Main.js index 248b8103736c..f4cbc7d8dffa 100644 --- a/test/cli/samples/sourcemap-inline/expected/Main.js +++ b/test/cli/samples/sourcemap-inline/expected/Main.js @@ -65,11 +65,18 @@ function detachNode(node) { function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function assign(tar, src) { @@ -125,11 +132,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -165,8 +168,16 @@ function blankObject() { return Object.create(null); } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function callAll(fns) { while (fns && fns.length) fns.shift()(); } export default Main; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0= diff --git a/test/cli/samples/sourcemap/expected/Main.js b/test/cli/samples/sourcemap/expected/Main.js index 59ed9b736704..43ee0b6b7f0d 100644 --- a/test/cli/samples/sourcemap/expected/Main.js +++ b/test/cli/samples/sourcemap/expected/Main.js @@ -65,11 +65,18 @@ function detachNode(node) { function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function assign(tar, src) { @@ -125,11 +132,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -165,6 +168,14 @@ function blankObject() { return Object.create(null); } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function callAll(fns) { while (fns && fns.length) fns.shift()(); } diff --git a/test/cli/samples/sourcemap/expected/Main.js.map b/test/cli/samples/sourcemap/expected/Main.js.map index eab12a290fc6..a6fe370c6987 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"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 ef8e170b3968..e3beb9d80ff4 100644 --- a/test/cli/samples/store/expected/Main.js +++ b/test/cli/samples/store/expected/Main.js @@ -85,11 +85,18 @@ function detachNode(node) { function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function assign(tar, src) { @@ -149,11 +156,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -191,6 +194,14 @@ function blankObject() { return Object.create(null); } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function callAll(fns) { while (fns && fns.length) fns.shift()(); } diff --git a/test/js/samples/action/expected-bundle.js b/test/js/samples/action/expected-bundle.js index d47781ac82c9..659a47019f90 100644 --- a/test/js/samples/action/expected-bundle.js +++ b/test/js/samples/action/expected-bundle.js @@ -54,17 +54,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -82,11 +97,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/bind-width-height/expected-bundle.js b/test/js/samples/bind-width-height/expected-bundle.js index a7f8a3f6167d..f0232218ac90 100644 --- a/test/js/samples/bind-width-height/expected-bundle.js +++ b/test/js/samples/bind-width-height/expected-bundle.js @@ -86,17 +86,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -114,11 +129,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -200,18 +211,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - callAll(this._beforecreate); + flush(this); } } diff --git a/test/js/samples/bind-width-height/expected.js b/test/js/samples/bind-width-height/expected.js index 5f0990fa00e9..bb2bf2554a0f 100644 --- a/test/js/samples/bind-width-height/expected.js +++ b/test/js/samples/bind-width-height/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { addResizeListener, assign, callAll, createElement, detachNode, init, insert, noop, proto } from "svelte/shared.js"; +import { addResizeListener, assign, createElement, detachNode, flush, init, insert, noop, proto } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var div, div_resize_listener; @@ -37,18 +37,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - callAll(this._beforecreate); + flush(this); } } 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 3c2ccba90e88..58f2fbb09c63 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -66,17 +66,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -94,11 +109,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/component-static-array/expected-bundle.js b/test/js/samples/component-static-array/expected-bundle.js index 30534f977e11..3bbb1ede2714 100644 --- a/test/js/samples/component-static-array/expected-bundle.js +++ b/test/js/samples/component-static-array/expected-bundle.js @@ -42,17 +42,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -70,11 +85,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -153,23 +164,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } diff --git a/test/js/samples/component-static-array/expected.js b/test/js/samples/component-static-array/expected.js index bae0c850f7dd..2b18d210a642 100644 --- a/test/js/samples/component-static-array/expected.js +++ b/test/js/samples/component-static-array/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, callAll, init, noop, proto } from "svelte/shared.js"; +import { assign, flush, init, noop, proto } from "svelte/shared.js"; var Nested = window.Nested; @@ -34,23 +34,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js index de9fc1a4a239..98f6b26fec3d 100644 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -46,17 +46,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -74,11 +89,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -157,23 +168,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } diff --git a/test/js/samples/component-static-immutable/expected.js b/test/js/samples/component-static-immutable/expected.js index f40f060325b2..72e03ffe7c2e 100644 --- a/test/js/samples/component-static-immutable/expected.js +++ b/test/js/samples/component-static-immutable/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { _differsImmutable, assign, callAll, init, noop, proto } from "svelte/shared.js"; +import { _differsImmutable, assign, flush, init, noop, proto } from "svelte/shared.js"; var Nested = window.Nested; @@ -34,23 +34,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js index de9fc1a4a239..98f6b26fec3d 100644 --- a/test/js/samples/component-static-immutable2/expected-bundle.js +++ b/test/js/samples/component-static-immutable2/expected-bundle.js @@ -46,17 +46,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -74,11 +89,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -157,23 +168,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } diff --git a/test/js/samples/component-static-immutable2/expected.js b/test/js/samples/component-static-immutable2/expected.js index f40f060325b2..72e03ffe7c2e 100644 --- a/test/js/samples/component-static-immutable2/expected.js +++ b/test/js/samples/component-static-immutable2/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { _differsImmutable, assign, callAll, init, noop, proto } from "svelte/shared.js"; +import { _differsImmutable, assign, flush, init, noop, proto } from "svelte/shared.js"; var Nested = window.Nested; @@ -34,23 +34,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index af59f9e89365..4c394bba1d3e 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -42,17 +42,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -70,11 +85,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -153,23 +164,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } diff --git a/test/js/samples/component-static/expected.js b/test/js/samples/component-static/expected.js index 1a5631fc58a6..e619014b678f 100644 --- a/test/js/samples/component-static/expected.js +++ b/test/js/samples/component-static/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, callAll, init, noop, proto } from "svelte/shared.js"; +import { assign, flush, init, noop, proto } from "svelte/shared.js"; var Nested = window.Nested; @@ -34,23 +34,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index a2ba378a2a5b..94cb7c3ef397 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -42,17 +42,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -70,11 +85,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index f3d74e22d287..703ef5f6c045 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -58,17 +58,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -86,11 +101,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { 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 4fe3a903fc0d..0bb956d28549 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -54,17 +54,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -82,11 +97,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/debug-empty/expected-bundle.js b/test/js/samples/debug-empty/expected-bundle.js index 36f2b87a8025..0faf822be3fd 100644 --- a/test/js/samples/debug-empty/expected-bundle.js +++ b/test/js/samples/debug-empty/expected-bundle.js @@ -79,17 +79,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -107,11 +122,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { 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 a6c539929c44..521d57af5b23 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 @@ -85,17 +85,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -113,11 +128,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/debug-foo/expected-bundle.js b/test/js/samples/debug-foo/expected-bundle.js index 8e2147c3226a..5cc1c7a4692b 100644 --- a/test/js/samples/debug-foo/expected-bundle.js +++ b/test/js/samples/debug-foo/expected-bundle.js @@ -85,17 +85,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -113,11 +128,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js index ead082d78f33..eae32e976c59 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ b/test/js/samples/deconflict-builtins/expected-bundle.js @@ -76,17 +76,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -104,11 +119,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index 45e4bed14191..28b8d1f46bb4 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -47,17 +47,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -75,11 +90,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -152,10 +163,6 @@ function SvelteComponent(options) { this._state = assign(data_1(), options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - } - this._fragment = create_main_fragment(this, this._state); this.root._oncreate.push(() => { @@ -167,7 +174,7 @@ function SvelteComponent(options) { this._fragment.c(); this._mount(options.target, options.anchor); - callAll(this._oncreate); + flush(this); } } diff --git a/test/js/samples/deconflict-globals/expected.js b/test/js/samples/deconflict-globals/expected.js index 275f189df70e..daaf8005c2a0 100644 --- a/test/js/samples/deconflict-globals/expected.js +++ b/test/js/samples/deconflict-globals/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, assignTrue, callAll, init, noop, proto } from "svelte/shared.js"; +import { assign, assignTrue, flush, init, noop, proto } from "svelte/shared.js"; function data_1() { return { @@ -29,10 +29,6 @@ function SvelteComponent(options) { this._state = assign(data_1(), options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - } - this._fragment = create_main_fragment(this, this._state); this.root._oncreate.push(() => { @@ -44,7 +40,7 @@ function SvelteComponent(options) { this._fragment.c(); this._mount(options.target, options.anchor); - callAll(this._oncreate); + flush(this); } } 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 0887f4261243..73fdae32238f 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 @@ -79,17 +79,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -107,11 +122,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js index b9e7b562652b..d981b929a7f8 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -58,17 +58,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -86,11 +101,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { 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 30890b83a3be..3be0e2a2705c 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 @@ -62,17 +62,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -90,11 +105,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { 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 9c006e287017..5b73e5176237 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 @@ -62,17 +62,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -90,11 +105,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { 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 01fb8671cea0..ce97c56af5ef 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -78,17 +78,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -106,11 +121,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { 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 57ba9366ab3e..1cfdf681f0db 100644 --- a/test/js/samples/each-block-keyed-animated/expected-bundle.js +++ b/test/js/samples/each-block-keyed-animated/expected-bundle.js @@ -381,17 +381,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -409,11 +424,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/each-block-keyed/expected-bundle.js b/test/js/samples/each-block-keyed/expected-bundle.js index 7242dc98bae9..1cc34f445573 100644 --- a/test/js/samples/each-block-keyed/expected-bundle.js +++ b/test/js/samples/each-block-keyed/expected-bundle.js @@ -161,17 +161,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -189,11 +204,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 73526d1c619f..23327a276a20 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -54,17 +54,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -82,11 +97,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js index baddc6b82e07..91eaa6cd5b11 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -54,17 +54,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -82,11 +97,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { 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 5d410c6ae884..83c3f60db0d4 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -58,17 +58,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -86,11 +101,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 27d7b8a5f262..24b9e526cd63 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -58,17 +58,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -86,11 +101,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { 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 c0f3ff99d294..78e6cc7e404f 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -58,17 +58,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -86,11 +101,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { 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 b04307dc3cda..9fd8e681a638 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -58,17 +58,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -86,11 +101,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js index ee08f28f21a1..d8f9b7d7d2c6 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -58,17 +58,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -86,11 +101,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js index 1ec722ca2d8e..b46055315e23 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -58,17 +58,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -86,11 +101,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/input-files/expected-bundle.js b/test/js/samples/input-files/expected-bundle.js index 1a6376f19353..b3218c7fd4b3 100644 --- a/test/js/samples/input-files/expected-bundle.js +++ b/test/js/samples/input-files/expected-bundle.js @@ -66,17 +66,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -94,11 +109,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/input-range/expected-bundle.js b/test/js/samples/input-range/expected-bundle.js index f9b53e91a5da..2f53e740ea47 100644 --- a/test/js/samples/input-range/expected-bundle.js +++ b/test/js/samples/input-range/expected-bundle.js @@ -70,17 +70,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -98,11 +113,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { 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 c3abad14fe0b..b5f7a90f8c37 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -66,17 +66,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -94,11 +109,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index e72c5538d528..cd841f8a2d3e 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -60,17 +60,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -88,11 +103,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index 4af5ac49d37a..d9f961f564fa 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -70,17 +70,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -98,11 +113,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -232,18 +243,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - callAll(this._beforecreate); + flush(this); } } diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index 59dc55b52831..97753a199552 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { addListener, assign, callAll, createElement, detachNode, init, insert, proto, removeListener, timeRangesToArray } from "svelte/shared.js"; +import { addListener, assign, createElement, detachNode, flush, init, insert, proto, removeListener, timeRangesToArray } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var audio, audio_is_paused = true, audio_updating = false, audio_animationframe; @@ -85,18 +85,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - callAll(this._beforecreate); + flush(this); } } diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 649f6b1f6121..b890d8bed5dd 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -56,17 +56,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -84,11 +99,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { @@ -180,23 +191,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index f7d1462a801f..8e47d1b1d35a 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, callAll, createText, detachNode, init, insert, noop, proto } from "svelte/shared.js"; +import { assign, createText, detachNode, flush, init, insert, noop, proto } from "svelte/shared.js"; import Imported from 'Imported.html'; @@ -48,23 +48,13 @@ function SvelteComponent(options) { this._state = assign({}, options.data); this._intro = true; - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; + flush(this); } } diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 5781b383a137..fa63c7850206 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -42,17 +42,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -70,11 +85,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index 4fa8bb9e34c3..269f6ca1f353 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -62,17 +62,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -90,11 +105,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index e994b9fdfc31..f0afba9d24a3 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -42,17 +42,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -70,11 +85,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { 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 e9c3391f88a7..4065ba55adb2 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -66,17 +66,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -94,11 +109,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) { diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index 4c835f62b32a..7823390a2cc2 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -66,17 +66,32 @@ function fire(eventName, data) { } } +function flush(component) { + component._lock = true; + callAll(component._beforecreate); + callAll(component._oncreate); + callAll(component._aftercreate); + component._lock = false; +} + function get() { return this._state; } function init(component, options) { component._handlers = blankObject(); + component._slots = blankObject(); component._bind = options._bind; component.options = options; component.root = options.root || component; component.store = options.store || component.root.store; + + if (!options.root) { + component._beforecreate = []; + component._oncreate = []; + component._aftercreate = []; + } } function on(eventName, handler) { @@ -94,11 +109,7 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; + flush(this.root); } function _set(newState) {