diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts
index 4dc638676d..3a20f1b549 100644
--- a/src/generators/dom/index.ts
+++ b/src/generators/dom/index.ts
@@ -154,7 +154,7 @@ export default function dom(
${options.dev && `this._debugName = '${debugName}';`}
${options.dev && !generator.customElement &&
`if (!options || (!options.target && !options._root)) throw new Error("'target' is a required option");`}
- this.options = options;
+ @init(this, options);
${generator.usesRefs && `this.refs = {};`}
this._state = ${templateProperties.data
? `@assign(@template.data(), options.data)`
@@ -169,17 +169,8 @@ export default function dom(
${generator.bindingGroups.length &&
`this._bindingGroups = [${Array(generator.bindingGroups.length).fill('[]').join(', ')}];`}
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
${templateProperties.ondestroy && `this._handlers.destroy = [@template.ondestroy]`}
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
${generator.slots.size && `this._slotted = options.slots || {};`}
${generator.customElement ?
diff --git a/src/generators/dom/visitors/EachBlock.ts b/src/generators/dom/visitors/EachBlock.ts
index e0d941511e..03c0918ce0 100644
--- a/src/generators/dom/visitors/EachBlock.ts
+++ b/src/generators/dom/visitors/EachBlock.ts
@@ -160,7 +160,7 @@ function keyed(
const last = block.getUniqueName(`${each_block}_last`);
const expected = block.getUniqueName(`${each_block}_expected`);
- block.addVariable(lookup, `Object.create(null)`);
+ block.addVariable(lookup, `@blankObject()`);
block.addVariable(head);
block.addVariable(last);
diff --git a/src/shared/index.js b/src/shared/index.js
index 34d85897df..dcc2895831 100644
--- a/src/shared/index.js
+++ b/src/shared/index.js
@@ -4,6 +4,10 @@ export * from './dom.js';
export * from './transitions.js';
export * from './utils.js';
+export function blankObject() {
+ return Object.create(null);
+}
+
export function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -46,10 +50,6 @@ export function dispatchObservers(component, group, changed, newState, oldState)
}
}
-export function get(key) {
- return key ? this._state[key] : this._state;
-}
-
export function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -60,6 +60,20 @@ export function fire(eventName, data) {
}
}
+export function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+export function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
export function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
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 d9449d5c66..381689510f 100644
--- a/test/js/samples/collapses-text-around-comments/expected-bundle.js
+++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js
@@ -37,6 +37,10 @@ function setAttribute(node, attribute, value) {
node.setAttribute(attribute, value);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -72,10 +76,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -86,6 +86,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -175,7 +189,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
var template = (function() {
return {
@@ -230,20 +244,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = assign(template.data(), options.data);
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
if (!document.getElementById("svelte-3590263702-style")) add_css();
this._fragment = create_main_fragment(this._state, this);
diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js
index 7a027c389d..9f28fa8507 100644
--- a/test/js/samples/collapses-text-around-comments/expected.js
+++ b/test/js/samples/collapses-text-around-comments/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto, setAttribute } from "svelte/shared.js";
+import { appendNode, assign, createElement, createText, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js";
var template = (function() {
return {
@@ -55,20 +55,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = assign(template.data(), options.data);
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
if (!document.getElementById("svelte-3590263702-style")) add_css();
this._fragment = create_main_fragment(this._state, this);
diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js
index 8dad6f4adc..14b5ea92f9 100644
--- a/test/js/samples/computed-collapsed-if/expected-bundle.js
+++ b/test/js/samples/computed-collapsed-if/expected-bundle.js
@@ -13,6 +13,10 @@ function assign(target) {
return target;
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -48,10 +52,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -62,6 +62,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -151,7 +165,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
var template = (function() {
return {
@@ -178,21 +192,10 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
this._recompute({}, this._state, {}, true);
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js
index 60adf0376e..b95290e5fa 100644
--- a/test/js/samples/computed-collapsed-if/expected.js
+++ b/test/js/samples/computed-collapsed-if/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { assign, differs, noop, proto } from "svelte/shared.js";
+import { assign, differs, init, noop, proto } from "svelte/shared.js";
var template = (function() {
return {
@@ -27,21 +27,10 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
this._recompute({}, this._state, {}, true);
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js
index d12dbea66a..9ffeb2f221 100644
--- a/test/js/samples/css-media-query/expected-bundle.js
+++ b/test/js/samples/css-media-query/expected-bundle.js
@@ -33,6 +33,10 @@ function setAttribute(node, attribute, value) {
node.setAttribute(attribute, value);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -68,10 +72,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -82,6 +82,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -171,7 +185,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function encapsulateStyles(node) {
setAttribute(node, "svelte-2363328337", "");
@@ -212,20 +226,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
if (!document.getElementById("svelte-2363328337-style")) add_css();
this._fragment = create_main_fragment(this._state, this);
diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js
index a51d9d0f7a..a70623ec7b 100644
--- a/test/js/samples/css-media-query/expected.js
+++ b/test/js/samples/css-media-query/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { appendNode, assign, createElement, detachNode, insertNode, noop, proto, setAttribute } from "svelte/shared.js";
+import { appendNode, assign, createElement, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js";
function encapsulateStyles(node) {
setAttribute(node, "svelte-2363328337", "");
@@ -41,20 +41,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
if (!document.getElementById("svelte-2363328337-style")) add_css();
this._fragment = create_main_fragment(this._state, this);
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 bfcc815643..7e04a00dd9 100644
--- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js
+++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js
@@ -33,6 +33,10 @@ function createText(data) {
return document.createTextNode(data);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -68,10 +72,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -82,6 +82,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -171,7 +185,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var div, text;
@@ -200,20 +214,9 @@ function create_main_fragment(state, component) {
class SvelteComponent extends HTMLElement {
constructor(options = {}) {
super();
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = ``;
diff --git a/test/js/samples/css-shadow-dom-keyframes/expected.js b/test/js/samples/css-shadow-dom-keyframes/expected.js
index 6e4ce0a044..6d0b37f175 100644
--- a/test/js/samples/css-shadow-dom-keyframes/expected.js
+++ b/test/js/samples/css-shadow-dom-keyframes/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
+import { appendNode, assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment(state, component) {
var div, text;
@@ -29,20 +29,9 @@ function create_main_fragment(state, component) {
class SvelteComponent extends HTMLElement {
constructor(options = {}) {
super();
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = ``;
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 17dbba5d17..f72914e256 100644
--- a/test/js/samples/each-block-changed-check/expected-bundle.js
+++ b/test/js/samples/each-block-changed-check/expected-bundle.js
@@ -46,6 +46,10 @@ function createText(data) {
return document.createTextNode(data);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -81,10 +85,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -95,6 +95,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -184,7 +198,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var text, p, text_1;
@@ -325,20 +339,9 @@ function create_each_block(state, each_block_value, comment, i, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js
index 50aea24e12..099d665310 100644
--- a/test/js/samples/each-block-changed-check/expected.js
+++ b/test/js/samples/each-block-changed-check/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { appendNode, assign, createElement, createText, destroyEach, detachAfter, detachNode, insertNode, noop, proto } from "svelte/shared.js";
+import { appendNode, assign, createElement, createText, destroyEach, detachAfter, detachNode, init, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment(state, component) {
var text, p, text_1;
@@ -141,20 +141,9 @@ function create_each_block(state, each_block_value, comment, i, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js
index 00e24ed978..022592786b 100644
--- a/test/js/samples/event-handlers-custom/expected-bundle.js
+++ b/test/js/samples/event-handlers-custom/expected-bundle.js
@@ -33,6 +33,10 @@ function createText(data) {
return document.createTextNode(data);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -68,10 +72,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -82,6 +82,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -171,7 +185,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
var template = (function() {
return {
@@ -223,20 +237,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js
index 304ee13841..cf2bf6a8ec 100644
--- a/test/js/samples/event-handlers-custom/expected.js
+++ b/test/js/samples/event-handlers-custom/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
+import { appendNode, assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js";
var template = (function() {
return {
@@ -52,20 +52,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
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 d67e038a00..8f91bf4175 100644
--- a/test/js/samples/if-block-no-update/expected-bundle.js
+++ b/test/js/samples/if-block-no-update/expected-bundle.js
@@ -37,6 +37,10 @@ function createComment() {
return document.createComment('');
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -72,10 +76,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -86,6 +86,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -175,7 +189,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var if_block_anchor;
@@ -267,20 +281,9 @@ function select_block_type(state) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js
index 45e01ab96d..82e090d93e 100644
--- a/test/js/samples/if-block-no-update/expected.js
+++ b/test/js/samples/if-block-no-update/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { appendNode, assign, createComment, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
+import { appendNode, assign, createComment, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment(state, component) {
var if_block_anchor;
@@ -92,20 +92,9 @@ function select_block_type(state) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js
index 8bb4ac429d..7007f2830f 100644
--- a/test/js/samples/if-block-simple/expected-bundle.js
+++ b/test/js/samples/if-block-simple/expected-bundle.js
@@ -37,6 +37,10 @@ function createComment() {
return document.createComment('');
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -72,10 +76,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -86,6 +86,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -175,7 +189,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var if_block_anchor;
@@ -242,20 +256,9 @@ function create_if_block(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js
index d128a6a4ec..53cf640760 100644
--- a/test/js/samples/if-block-simple/expected.js
+++ b/test/js/samples/if-block-simple/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { appendNode, assign, createComment, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
+import { appendNode, assign, createComment, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment(state, component) {
var if_block_anchor;
@@ -67,20 +67,9 @@ function create_if_block(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
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 b5e54c7e6e..baee24460d 100644
--- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js
+++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js
@@ -29,6 +29,10 @@ function setStyle(node, key, value) {
node.style.setProperty(key, value);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -64,10 +68,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -78,6 +78,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -167,7 +181,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var div;
@@ -206,20 +220,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/inline-style-optimized-multiple/expected.js b/test/js/samples/inline-style-optimized-multiple/expected.js
index f54ea5d785..b8b84bccde 100644
--- a/test/js/samples/inline-style-optimized-multiple/expected.js
+++ b/test/js/samples/inline-style-optimized-multiple/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { assign, createElement, detachNode, insertNode, noop, proto, setStyle } from "svelte/shared.js";
+import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js";
function create_main_fragment(state, component) {
var div;
@@ -39,20 +39,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
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 21561be133..36f7e7088e 100644
--- a/test/js/samples/inline-style-optimized-url/expected-bundle.js
+++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js
@@ -29,6 +29,10 @@ function setStyle(node, key, value) {
node.style.setProperty(key, value);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -64,10 +68,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -78,6 +78,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -167,7 +181,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var div;
@@ -201,20 +215,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/inline-style-optimized-url/expected.js b/test/js/samples/inline-style-optimized-url/expected.js
index cb17cedca8..8af7163c19 100644
--- a/test/js/samples/inline-style-optimized-url/expected.js
+++ b/test/js/samples/inline-style-optimized-url/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { assign, createElement, detachNode, insertNode, noop, proto, setStyle } from "svelte/shared.js";
+import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js";
function create_main_fragment(state, component) {
var div;
@@ -34,20 +34,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js
index 4fcd4211a5..8fc1d52c22 100644
--- a/test/js/samples/inline-style-optimized/expected-bundle.js
+++ b/test/js/samples/inline-style-optimized/expected-bundle.js
@@ -29,6 +29,10 @@ function setStyle(node, key, value) {
node.style.setProperty(key, value);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -64,10 +68,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -78,6 +78,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -167,7 +181,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var div;
@@ -201,20 +215,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/inline-style-optimized/expected.js b/test/js/samples/inline-style-optimized/expected.js
index 182250bf0c..ba05d8a693 100644
--- a/test/js/samples/inline-style-optimized/expected.js
+++ b/test/js/samples/inline-style-optimized/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { assign, createElement, detachNode, insertNode, noop, proto, setStyle } from "svelte/shared.js";
+import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js";
function create_main_fragment(state, component) {
var div;
@@ -34,20 +34,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js
index 7ca2e8323d..b37c46cc1c 100644
--- a/test/js/samples/inline-style-unoptimized/expected-bundle.js
+++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js
@@ -29,6 +29,10 @@ function createText(data) {
return document.createTextNode(data);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -64,10 +68,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -78,6 +78,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -167,7 +181,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var div, text, div_1, div_1_style_value;
@@ -212,20 +226,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/inline-style-unoptimized/expected.js b/test/js/samples/inline-style-unoptimized/expected.js
index 7fbb2eab0c..a8fa992ded 100644
--- a/test/js/samples/inline-style-unoptimized/expected.js
+++ b/test/js/samples/inline-style-unoptimized/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
+import { assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment(state, component) {
var div, text, div_1, div_1_style_value;
@@ -45,20 +45,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
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 c5d2693d15..b1c6c3b8e5 100644
--- a/test/js/samples/input-without-blowback-guard/expected-bundle.js
+++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js
@@ -33,6 +33,10 @@ function removeListener(node, event, handler) {
node.removeEventListener(event, handler, false);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -68,10 +72,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -82,6 +82,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -171,7 +185,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var input;
@@ -212,20 +226,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/input-without-blowback-guard/expected.js b/test/js/samples/input-without-blowback-guard/expected.js
index 1052a5cffa..ab01d04de3 100644
--- a/test/js/samples/input-without-blowback-guard/expected.js
+++ b/test/js/samples/input-without-blowback-guard/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { addListener, assign, createElement, detachNode, insertNode, proto, removeListener } from "svelte/shared.js";
+import { addListener, assign, createElement, detachNode, init, insertNode, proto, removeListener } from "svelte/shared.js";
function create_main_fragment(state, component) {
var input;
@@ -41,20 +41,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js
index e96195727c..c950e0ddb1 100644
--- a/test/js/samples/legacy-input-type/expected-bundle.js
+++ b/test/js/samples/legacy-input-type/expected-bundle.js
@@ -31,6 +31,10 @@ function setInputType(input, type) {
} catch (e) {}
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -66,10 +70,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -80,6 +80,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -169,7 +183,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var input;
@@ -199,20 +213,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/legacy-input-type/expected.js b/test/js/samples/legacy-input-type/expected.js
index bd2353a560..082b8d3208 100644
--- a/test/js/samples/legacy-input-type/expected.js
+++ b/test/js/samples/legacy-input-type/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { assign, createElement, detachNode, insertNode, noop, proto, setInputType } from "svelte/shared.js";
+import { assign, createElement, detachNode, init, insertNode, noop, proto, setInputType } from "svelte/shared.js";
function create_main_fragment(state, component) {
var input;
@@ -30,20 +30,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/legacy-quote-class/expected-bundle.js b/test/js/samples/legacy-quote-class/expected-bundle.js
index 1ae85825e7..9d0e225527 100644
--- a/test/js/samples/legacy-quote-class/expected-bundle.js
+++ b/test/js/samples/legacy-quote-class/expected-bundle.js
@@ -48,6 +48,10 @@ function claimElement (nodes, name, attributes, svg) {
return svg ? createSvgElement(name) : createElement(name);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -83,10 +87,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -97,6 +97,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -186,7 +200,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var div;
@@ -224,20 +238,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/legacy-quote-class/expected.js b/test/js/samples/legacy-quote-class/expected.js
index f98967ca7e..09d185216e 100644
--- a/test/js/samples/legacy-quote-class/expected.js
+++ b/test/js/samples/legacy-quote-class/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { assign, children, claimElement, createElement, detachNode, insertNode, noop, proto } from "svelte/shared.js";
+import { assign, children, claimElement, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment(state, component) {
var div;
@@ -38,20 +38,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js
index 36efc05ee0..ce26e1ac63 100644
--- a/test/js/samples/media-bindings/expected-bundle.js
+++ b/test/js/samples/media-bindings/expected-bundle.js
@@ -41,6 +41,10 @@ function timeRangesToArray(ranges) {
return array;
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -76,10 +80,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -90,6 +90,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -179,7 +193,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var audio, audio_updating = false, audio_animationframe, audio_paused_value = true;
@@ -288,20 +302,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
if (!options._root) {
this._oncreate = [];
this._beforecreate = [];
diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js
index 02a16f72f8..ca7837c41c 100644
--- a/test/js/samples/media-bindings/expected.js
+++ b/test/js/samples/media-bindings/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { addListener, assign, callAll, createElement, detachNode, insertNode, proto, removeListener, timeRangesToArray } from "svelte/shared.js";
+import { addListener, assign, callAll, createElement, detachNode, init, insertNode, proto, removeListener, timeRangesToArray } from "svelte/shared.js";
function create_main_fragment(state, component) {
var audio, audio_updating = false, audio_animationframe, audio_paused_value = true;
@@ -109,20 +109,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
if (!options._root) {
this._oncreate = [];
this._beforecreate = [];
diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js
index 48f69ac7d9..f1f284a01f 100644
--- a/test/js/samples/non-imported-component/expected-bundle.js
+++ b/test/js/samples/non-imported-component/expected-bundle.js
@@ -27,6 +27,10 @@ function createText(data) {
return document.createTextNode(data);
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -62,10 +66,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -76,6 +76,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -165,7 +179,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
var template = (function() {
return {
@@ -215,20 +229,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
if (!options._root) {
this._oncreate = [];
this._beforecreate = [];
diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js
index 61034fa15d..a7c1ad99a8 100644
--- a/test/js/samples/non-imported-component/expected.js
+++ b/test/js/samples/non-imported-component/expected.js
@@ -1,8 +1,8 @@
import Imported from 'Imported.html';
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { assign, callAll, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
+import { assign, callAll, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js";
var template = (function() {
return {
@@ -52,20 +52,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
if (!options._root) {
this._oncreate = [];
this._beforecreate = [];
diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js
index 133875e583..c1556145d3 100644
--- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js
+++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js
@@ -13,6 +13,10 @@ function assign(target) {
return target;
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -48,10 +52,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -62,6 +62,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -151,7 +165,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
var template = (function() {
return {
@@ -177,21 +191,11 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
this._handlers.destroy = [template.ondestroy];
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
var oncreate = template.oncreate.bind(this);
if (!options._root) {
diff --git a/test/js/samples/onrender-onteardown-rewritten/expected.js b/test/js/samples/onrender-onteardown-rewritten/expected.js
index 230f69cffa..00323faf1c 100644
--- a/test/js/samples/onrender-onteardown-rewritten/expected.js
+++ b/test/js/samples/onrender-onteardown-rewritten/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { assign, callAll, noop, proto } from "svelte/shared.js";
+import { assign, callAll, init, noop, proto } from "svelte/shared.js";
var template = (function() {
return {
@@ -26,21 +26,11 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
this._handlers.destroy = [template.ondestroy]
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
var oncreate = template.oncreate.bind(this);
if (!options._root) {
diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js
index 1ee808404a..a5c4ff68f8 100644
--- a/test/js/samples/setup-method/expected-bundle.js
+++ b/test/js/samples/setup-method/expected-bundle.js
@@ -13,6 +13,10 @@ function assign(target) {
return target;
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -48,10 +52,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -62,6 +62,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -151,7 +165,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
var template = (function() {
return {
@@ -188,20 +202,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/setup-method/expected.js b/test/js/samples/setup-method/expected.js
index 5d4a7e3dac..a544e229bc 100644
--- a/test/js/samples/setup-method/expected.js
+++ b/test/js/samples/setup-method/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { assign, noop, proto } from "svelte/shared.js";
+import { assign, init, noop, proto } from "svelte/shared.js";
var template = (function() {
return {
@@ -37,20 +37,9 @@ function create_main_fragment(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
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 1fb76590dc..ae00877549 100644
--- a/test/js/samples/use-elements-as-anchors/expected-bundle.js
+++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js
@@ -37,6 +37,10 @@ function createComment() {
return document.createComment('');
}
+function blankObject() {
+ return Object.create(null);
+}
+
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
@@ -72,10 +76,6 @@ function dispatchObservers(component, group, changed, newState, oldState) {
}
}
-function get(key) {
- return key ? this._state[key] : this._state;
-}
-
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
@@ -86,6 +86,20 @@ function fire(eventName, data) {
}
}
+function get(key) {
+ return key ? this._state[key] : this._state;
+}
+
+function init(component, options) {
+ component.options = options;
+
+ component._observers = { pre: blankObject(), post: blankObject() };
+ component._handlers = blankObject();
+ component._root = options._root || component;
+ component._yield = options._yield;
+ component._bind = options._bind;
+}
+
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
@@ -175,7 +189,7 @@ var proto = {
_unmount: _unmount
};
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
function create_main_fragment(state, component) {
var div, text, p, text_1, text_2, text_3, text_4, p_1, text_5, text_6, text_8, if_block_4_anchor;
@@ -430,20 +444,9 @@ function create_if_block_4(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {
diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js
index 2cb72d2ce3..6c18931e7a 100644
--- a/test/js/samples/use-elements-as-anchors/expected.js
+++ b/test/js/samples/use-elements-as-anchors/expected.js
@@ -1,6 +1,6 @@
-/* generated by Svelte v1.39.2 */
+/* generated by Svelte v1.39.3 */
-import { appendNode, assign, createComment, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
+import { appendNode, assign, createComment, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment(state, component) {
var div, text, p, text_1, text_2, text_3, text_4, p_1, text_5, text_6, text_8, if_block_4_anchor;
@@ -255,20 +255,9 @@ function create_if_block_4(state, component) {
}
function SvelteComponent(options) {
- this.options = options;
+ init(this, options);
this._state = options.data || {};
- this._observers = {
- pre: Object.create(null),
- post: Object.create(null)
- };
-
- this._handlers = Object.create(null);
-
- this._root = options._root || this;
- this._yield = options._yield;
- this._bind = options._bind;
-
this._fragment = create_main_fragment(this._state, this);
if (options.target) {