diff --git a/test/js/samples/bind-width-height/expected-bundle.js b/test/js/samples/bind-width-height/expected-bundle.js index acc96ca79d..23fac43e0d 100644 --- a/test/js/samples/bind-width-height/expected-bundle.js +++ b/test/js/samples/bind-width-height/expected-bundle.js @@ -26,6 +26,10 @@ function addResizeListener(element, fn) { object.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;'); object.type = 'text/html'; + object.onload = () => { + object.contentDocument.defaultView.addEventListener('resize', fn); + }; + if (/Trident/.test(navigator.userAgent)) { element.appendChild(object); object.data = 'about:blank'; @@ -34,10 +38,6 @@ function addResizeListener(element, fn) { element.appendChild(object); } - object.onload = () => { - object.contentDocument.defaultView.addEventListener('resize', fn); - }; - return { cancel: () => { object.contentDocument.defaultView.removeEventListener('resize', fn); @@ -179,23 +179,22 @@ function create_main_fragment(component, ctx) { }, h: function hydrate() { - div_resize_listener = addResizeListener(div, div_resize_handler); component.root._beforecreate.push(div_resize_handler); }, m: function mount(target, anchor) { insertNode(div, target, anchor); + div_resize_listener = addResizeListener(div, div_resize_handler); }, p: noop, u: function unmount() { detachNode(div); + div_resize_listener.cancel(); }, - d: function destroy$$1() { - div_resize_listener.cancel(); - } + d: noop }; } @@ -203,11 +202,18 @@ function SvelteComponent(options) { init(this, options); this._state = assign({}, options.data); + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + } + this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); + + callAll(this._beforecreate); } } diff --git a/test/js/samples/bind-width-height/expected.js b/test/js/samples/bind-width-height/expected.js index 55e58033ee..eafdfe2a83 100644 --- a/test/js/samples/bind-width-height/expected.js +++ b/test/js/samples/bind-width-height/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { addResizeListener, assign, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; +import { addResizeListener, assign, callAll, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var div, div_resize_listener; @@ -16,23 +16,22 @@ function create_main_fragment(component, ctx) { }, h: function hydrate() { - div_resize_listener = addResizeListener(div, div_resize_handler); component.root._beforecreate.push(div_resize_handler); }, m: function mount(target, anchor) { insertNode(div, target, anchor); + div_resize_listener = addResizeListener(div, div_resize_handler); }, p: noop, u: function unmount() { detachNode(div); + div_resize_listener.cancel(); }, - d: function destroy() { - div_resize_listener.cancel(); - } + d: noop }; } @@ -40,11 +39,18 @@ function SvelteComponent(options) { init(this, options); this._state = assign({}, options.data); + if (!options.root) { + this._oncreate = []; + this._beforecreate = []; + } + this._fragment = create_main_fragment(this, this._state); if (options.target) { this._fragment.c(); this._mount(options.target, options.anchor); + + callAll(this._beforecreate); } }