From ca65638bf1e74fca9297f28e982c5967bc0b07a3 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 21 Apr 2018 21:06:59 -0400 Subject: [PATCH] update tests --- src/generators/dom/index.ts | 109 +++++++----------- src/shared/index.js | 10 ++ test/js/samples/action/expected-bundle.js | 10 ++ .../expected-bundle.js | 10 ++ .../expected-bundle.js | 16 ++- .../component-static-immutable/expected.js | 6 - .../expected-bundle.js | 16 ++- .../component-static-immutable2/expected.js | 6 - .../component-static/expected-bundle.js | 16 ++- test/js/samples/component-static/expected.js | 6 - .../computed-collapsed-if/expected-bundle.js | 10 ++ .../css-media-query/expected-bundle.js | 10 ++ .../expected-bundle.js | 12 +- .../css-shadow-dom-keyframes/expected.js | 2 +- .../deconflict-builtins/expected-bundle.js | 10 ++ .../deconflict-globals/expected-bundle.js | 27 +++-- .../js/samples/deconflict-globals/expected.js | 17 +-- .../expected-bundle.js | 10 ++ .../samples/do-use-dataset/expected-bundle.js | 10 ++ .../expected-bundle.js | 10 ++ .../expected-bundle.js | 10 ++ .../expected-bundle.js | 10 ++ .../event-handlers-custom/expected-bundle.js | 10 ++ .../head-no-whitespace/expected-bundle.js | 10 ++ .../if-block-no-update/expected-bundle.js | 10 ++ .../if-block-simple/expected-bundle.js | 10 ++ .../expected-bundle.js | 10 ++ .../expected-bundle.js | 10 ++ .../inline-style-optimized/expected-bundle.js | 10 ++ .../expected-bundle.js | 10 ++ .../expected-bundle.js | 10 ++ .../legacy-input-type/expected-bundle.js | 10 ++ .../samples/media-bindings/expected-bundle.js | 15 ++- test/js/samples/media-bindings/expected.js | 5 - .../method-arrow-function/expected-bundle.js | 10 ++ .../samples/method-async/expected-bundle.js | 10 ++ .../expected-bundle.js | 10 ++ .../expected-bundle.js | 10 ++ .../non-imported-component/expected-bundle.js | 16 ++- .../non-imported-component/expected.js | 6 - .../samples/setup-method/expected-bundle.js | 10 ++ test/js/samples/svg-title/expected-bundle.js | 10 ++ test/js/samples/title/expected-bundle.js | 10 ++ .../expected-bundle.js | 10 ++ .../window-binding-scroll/expected-bundle.js | 10 ++ 45 files changed, 425 insertions(+), 150 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index bc658217a9..0e801601cf 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -162,7 +162,6 @@ export default function dom( const constructorBody = deindent` ${options.dev && `this._debugName = '${debugName}';`} ${templateProperties.store && `this.store = %store();`} - ${generator.usesRefs && `this.refs = {};`} this._state = ${initialState.reduce((state, piece) => `@assign(${state}, ${piece})`)}; ${storeProps.length > 0 && `this.store._add(this, [${storeProps.map(prop => `"${prop.slice(1)}"`)}]);`} ${generator.metaBindings} @@ -193,71 +192,51 @@ export default function dom( }];` )} - ${generator.slots.size && `this._slotted = options.slots || {};`} - - ${generator.customElement ? - deindent` - this.attachShadow({ mode: 'open' }); - ${css.code && `this.shadowRoot.innerHTML = \`\`;`} + ${generator.customElement ? deindent` + ${css.code && `this.shadowRoot.innerHTML = \`\`;`} ` : (generator.stylesheet.hasStyles && options.css !== false && - `if (!document.getElementById("${generator.stylesheet.id}-style")) @add_css();`) - } - - ${hasInitHooks && deindent` - var self = this; - var _oncreate = function() { - var changed = { ${expectedProperties.map(p => `${p}: 1`).join(', ')} }; - ${templateProperties.onstate && `%onstate.call(self, { changed: changed, current: self._state });`} - ${templateProperties.oncreate && `%oncreate.call(self);`} - self.fire("update", { changed: changed, current: self._state }); - }; - `} - - ${(hasInitHooks || generator.hasComponents || generator.hasComplexBindings || generator.hasIntroTransitions) && deindent` - if (!options.root) { - this._oncreate = []; - ${(generator.hasComponents || generator.hasComplexBindings) && `this._beforecreate = [];`} - ${(generator.hasComponents || generator.hasIntroTransitions) && `this._aftercreate = [];`} - } - `} - - ${generator.slots.size && `this.slots = {};`} + `if (!document.getElementById("${generator.stylesheet.id}-style")) @add_css();`)} this._fragment = @create_main_fragment(this, this._state); ${hasInitHooks && deindent` - this.root._oncreate.push(_oncreate); - `} + this.root._oncreate.push(() => { + const changed = { ${expectedProperties.map(p => `${p}: 1`).join(', ')} }; + ${templateProperties.onstate && `%onstate.call(this, { changed, current: this._state });`} + ${templateProperties.oncreate && `%oncreate.call(this);`} + this.fire("update", { changed, current: this._state }); + });`} - ${generator.customElement ? deindent` - this._fragment.c(); - this._fragment.${block.hasIntroMethod ? 'i' : 'm'}(this.shadowRoot, null); - - if (options.target) this._mount(options.target, options.anchor); - ` : deindent` - if (options.target) { - ${generator.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(); - `} - this._mount(options.target, options.anchor); + ${generator.customElement ? + deindent` + this._fragment.c(); + this._fragment.${block.hasIntroMethod ? 'i' : 'm'}(this.shadowRoot, null); - ${(generator.hasComponents || generator.hasComplexBindings || hasInitHooks || generator.hasIntroTransitions) && deindent` - ${generator.hasComponents && `this._lock = true;`} - ${(generator.hasComponents || generator.hasComplexBindings) && `@callAll(this._beforecreate);`} - ${(generator.hasComponents || hasInitHooks) && `@callAll(this._oncreate);`} - ${(generator.hasComponents || generator.hasIntroTransitions) && `@callAll(this._aftercreate);`} - ${generator.hasComponents && `this._lock = false;`} - `} - } - `} + if (options.target) this._mount(options.target, options.anchor); + ` : + deindent` + if (options.target) { + ${generator.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(); + `} + this._mount(options.target, options.anchor); + + ${(generator.hasComponents || generator.hasComplexBindings || hasInitHooks || generator.hasIntroTransitions) && deindent` + ${generator.hasComponents && `this._lock = true;`} + ${(generator.hasComponents || generator.hasComplexBindings) && `@callAll(this._beforecreate);`} + ${(generator.hasComponents || hasInitHooks) && `@callAll(this._oncreate);`} + ${(generator.hasComponents || generator.hasIntroTransitions) && `@callAll(this._aftercreate);`} + ${generator.hasComponents && `this._lock = false;`} + `} + }`} `; const classMethods = []; @@ -318,6 +297,7 @@ export default function dom( super(); this._handlers = {}; this._init.call(this, options); + this.attachShadow({ mode: 'open' }); ${constructorBody} } @@ -336,19 +316,16 @@ export default function dom( ${classMethods.length && classMethods.join('\n\n')} - ${generator.slots.size && deindent` - connectedCallback() { - Object.keys(this._slotted).forEach(key => { - this.appendChild(this._slotted[key]); - }); - }`} - attributeChangedCallback(attr, oldValue, newValue) { this.set({ [attr]: newValue }); } - ${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent` + ${(generator.slots.size || generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent` connectedCallback() { + ${generator.slots.size && deindent` + Object.keys(this._slotted).forEach(key => { + this.appendChild(this._slotted[key]); + });`} ${generator.hasComponents && `this._lock = true;`} ${(generator.hasComponents || generator.hasComplexBindings) && `@callAll(this._beforecreate);`} ${(generator.hasComponents || templateProperties.oncreate) && `@callAll(this._oncreate);`} diff --git a/src/shared/index.js b/src/shared/index.js index cd13e37b00..2f50eb2fdc 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -79,10 +79,20 @@ export class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { diff --git a/test/js/samples/action/expected-bundle.js b/test/js/samples/action/expected-bundle.js index 6b0da6f682..07149e6d80 100644 --- a/test/js/samples/action/expected-bundle.js +++ b/test/js/samples/action/expected-bundle.js @@ -90,10 +90,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { 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 301d763485..bf9d293129 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -98,10 +98,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js index 99898b6e09..3a11a66a96 100644 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -78,10 +78,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { @@ -163,12 +173,6 @@ class SvelteComponent extends Component { super(options); this._state = assign({}, options.data); - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { diff --git a/test/js/samples/component-static-immutable/expected.js b/test/js/samples/component-static-immutable/expected.js index 7512269f6a..f25cd25c4c 100644 --- a/test/js/samples/component-static-immutable/expected.js +++ b/test/js/samples/component-static-immutable/expected.js @@ -37,12 +37,6 @@ class SvelteComponent extends Component { super(options); this._state = assign({}, options.data); - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js index 99898b6e09..3a11a66a96 100644 --- a/test/js/samples/component-static-immutable2/expected-bundle.js +++ b/test/js/samples/component-static-immutable2/expected-bundle.js @@ -78,10 +78,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { @@ -163,12 +173,6 @@ class SvelteComponent extends Component { super(options); this._state = assign({}, options.data); - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { diff --git a/test/js/samples/component-static-immutable2/expected.js b/test/js/samples/component-static-immutable2/expected.js index 7512269f6a..f25cd25c4c 100644 --- a/test/js/samples/component-static-immutable2/expected.js +++ b/test/js/samples/component-static-immutable2/expected.js @@ -37,12 +37,6 @@ class SvelteComponent extends Component { super(options); this._state = assign({}, options.data); - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index dd979af51e..c7af2ef324 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -78,10 +78,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { @@ -163,12 +173,6 @@ class SvelteComponent extends Component { super(options); this._state = assign({}, options.data); - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { diff --git a/test/js/samples/component-static/expected.js b/test/js/samples/component-static/expected.js index 541ebae801..d756f6fece 100644 --- a/test/js/samples/component-static/expected.js +++ b/test/js/samples/component-static/expected.js @@ -37,12 +37,6 @@ class SvelteComponent extends Component { super(options); this._state = assign({}, options.data); - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index a3dfffaa3b..c99ae4aba4 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -78,10 +78,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 9740530796..3b8421f7a6 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -94,10 +94,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 b772989469..bb77293d58 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -90,10 +90,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { @@ -168,9 +178,9 @@ class SvelteComponent extends HTMLElement { super(); this._handlers = {}; this._init.call(this, options); + this.attachShadow({ mode: 'open' }); this._state = assign({}, options.data); - this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ``; this._fragment = create_main_fragment(this, this._state); diff --git a/test/js/samples/css-shadow-dom-keyframes/expected.js b/test/js/samples/css-shadow-dom-keyframes/expected.js index 431e4e0b0c..1e46788412 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected.js @@ -30,9 +30,9 @@ class SvelteComponent extends HTMLElement { super(); this._handlers = {}; this._init.call(this, options); + this.attachShadow({ mode: 'open' }); this._state = assign({}, options.data); - this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ``; this._fragment = create_main_fragment(this, this._state); diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js index 5cd3fb63a1..dc77edef4f 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ b/test/js/samples/deconflict-builtins/expected-bundle.js @@ -108,10 +108,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index 1bb8e1cb15..8e04976809 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -78,10 +78,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { @@ -156,20 +166,13 @@ class SvelteComponent extends Component { super(options); this._state = assign(data_1(), options.data); - var self = this; - var _oncreate = function() { - var changed = { }; - oncreate.call(self); - self.fire("update", { changed: changed, current: self._state }); - }; - - if (!options.root) { - this._oncreate = []; - } - this._fragment = create_main_fragment(this, this._state); - this.root._oncreate.push(_oncreate); + this.root._oncreate.push(() => { + const changed = { }; + oncreate.call(this); + this.fire("update", { changed, current: this._state }); + }); if (options.target) { this._fragment.c(); diff --git a/test/js/samples/deconflict-globals/expected.js b/test/js/samples/deconflict-globals/expected.js index 7922871df4..9d785bbf50 100644 --- a/test/js/samples/deconflict-globals/expected.js +++ b/test/js/samples/deconflict-globals/expected.js @@ -31,20 +31,13 @@ class SvelteComponent extends Component { super(options); this._state = assign(data_1(), options.data); - var self = this; - var _oncreate = function() { - var changed = { }; - oncreate.call(self); - self.fire("update", { changed: changed, current: self._state }); - }; - - if (!options.root) { - this._oncreate = []; - } - this._fragment = create_main_fragment(this, this._state); - this.root._oncreate.push(_oncreate); + this.root._oncreate.push(() => { + const changed = { }; + oncreate.call(this); + this.fire("update", { changed, current: this._state }); + }); if (options.target) { this._fragment.c(); 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 1ed5fe4538..dc041f1e57 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 @@ -98,10 +98,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 0a1590ef97..466f905864 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -94,10 +94,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 c52d1e46af..0eae550e58 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 @@ -98,10 +98,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 e8a1b20748..f6c8a48173 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 @@ -98,10 +98,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 644030d9c0..6924aa1c01 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -110,10 +110,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 cac6cefdc1..dbf6271946 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -90,10 +90,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 1c249b5e36..4fbf19e00a 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -90,10 +90,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 d136aec41e..a3492c7c3b 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -94,10 +94,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 d50825b0dc..9221948e00 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -94,10 +94,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 f1ea22c66b..aa1946499f 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -94,10 +94,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 63fd122d37..905ebb024c 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -94,10 +94,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 fc4c0c7e7a..be3e62e122 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -94,10 +94,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 408622931e..909f9b3646 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -94,10 +94,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 a8c94e4aa7..02ec9bccd7 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -102,10 +102,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 2483c6329e..6da52e3914 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -96,10 +96,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index eef1e702d8..df5151a54e 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -106,10 +106,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { @@ -243,11 +253,6 @@ class SvelteComponent extends Component { super(options); this._state = assign({}, options.data); - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index 9e424a5c65..9f8a7f969f 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -89,11 +89,6 @@ class SvelteComponent extends Component { super(options); this._state = assign({}, options.data); - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { diff --git a/test/js/samples/method-arrow-function/expected-bundle.js b/test/js/samples/method-arrow-function/expected-bundle.js index 5209210a7a..0f9e112452 100644 --- a/test/js/samples/method-arrow-function/expected-bundle.js +++ b/test/js/samples/method-arrow-function/expected-bundle.js @@ -78,10 +78,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { diff --git a/test/js/samples/method-async/expected-bundle.js b/test/js/samples/method-async/expected-bundle.js index 6c939e0257..10f4c1e3fd 100644 --- a/test/js/samples/method-async/expected-bundle.js +++ b/test/js/samples/method-async/expected-bundle.js @@ -78,10 +78,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { diff --git a/test/js/samples/method-function-keyword/expected-bundle.js b/test/js/samples/method-function-keyword/expected-bundle.js index 2d8da4596a..6d7492f57a 100644 --- a/test/js/samples/method-function-keyword/expected-bundle.js +++ b/test/js/samples/method-function-keyword/expected-bundle.js @@ -78,10 +78,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { diff --git a/test/js/samples/method-non-function-expression/expected-bundle.js b/test/js/samples/method-non-function-expression/expected-bundle.js index 1562de15d7..3c4a6f8622 100644 --- a/test/js/samples/method-non-function-expression/expected-bundle.js +++ b/test/js/samples/method-non-function-expression/expected-bundle.js @@ -78,10 +78,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 81a7540dc1..f3d943a229 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -92,10 +92,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { @@ -187,12 +197,6 @@ class SvelteComponent extends Component { super(options); this._state = assign({}, options.data); - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index 830b989a72..4ddb5d64f4 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -48,12 +48,6 @@ class SvelteComponent extends Component { super(options); this._state = assign({}, options.data); - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - this._fragment = create_main_fragment(this, this._state); if (options.target) { diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 579d237136..523ad5eb90 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -78,10 +78,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index 8ba137a500..5d992714dd 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -98,10 +98,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) { diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index 8e75f1e4d6..55b3a2644e 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -78,10 +78,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 53b53a7dba..239be07fae 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -102,10 +102,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _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 3581e25a03..9c2e078249 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -98,10 +98,20 @@ class Component extends Base { _init(options) { this._bind = options._bind; + this._slotted = options.slots || {}; this.options = options; this.root = options.root || this; this.store = this.root.store || options.store; + + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } + + this.refs = {}; + this.slots = {}; } _set(newState) {