From 4a88c9ccb59a727bd57269a678bfd43ffd3800ed Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 25 Sep 2018 21:10:41 -0400 Subject: [PATCH] remove -bundle files --- test/js/index.js | 37 -- test/js/samples/action/expected-bundle.js | 212 ------ .../bind-width-height/expected-bundle.js | 235 ------- .../expected-bundle.js | 223 ------- .../component-static-array/expected-bundle.js | 188 ------ .../expected-bundle.js | 194 ------ .../expected-bundle.js | 194 ------ .../component-static/expected-bundle.js | 188 ------ .../computed-collapsed-if/expected-bundle.js | 187 ------ .../css-media-query/expected-bundle.js | 206 ------ .../expected-bundle.js | 215 ------- .../js/samples/debug-empty/expected-bundle.js | 254 -------- .../expected-bundle.js | 350 ---------- test/js/samples/debug-foo/expected-bundle.js | 348 ---------- .../samples/debug-ssr-foo/expected-bundle.js | 46 -- .../deconflict-builtins/expected-bundle.js | 290 --------- .../deconflict-globals/expected-bundle.js | 192 ------ .../expected-bundle.js | 264 -------- .../samples/do-use-dataset/expected-bundle.js | 208 ------ .../expected-bundle.js | 212 ------ .../expected-bundle.js | 210 ------ .../samples/dynamic-import/expected-bundle.js | 186 ------ .../expected-bundle.js | 331 ---------- .../expected-bundle.js | 609 ------------------ .../each-block-keyed/expected-bundle.js | 360 ----------- .../event-handlers-custom/expected-bundle.js | 211 ------ .../head-no-whitespace/expected-bundle.js | 197 ------ .../if-block-no-update/expected-bundle.js | 258 -------- .../if-block-simple/expected-bundle.js | 234 ------- .../expected-bundle.js | 206 ------ .../expected-bundle.js | 201 ------ .../inline-style-optimized/expected-bundle.js | 201 ------ .../expected-bundle.js | 212 ------ .../js/samples/input-files/expected-bundle.js | 219 ------- .../js/samples/input-range/expected-bundle.js | 222 ------- .../expected-bundle.js | 216 ------- .../legacy-input-type/expected-bundle.js | 199 ------ .../samples/media-bindings/expected-bundle.js | 267 -------- .../non-imported-component/expected-bundle.js | 215 ------- .../select-dynamic-value/expected-bundle.js | 227 ------- .../samples/setup-method/expected-bundle.js | 190 ------ .../ssr-no-oncreate-etc/expected-bundle.js | 46 -- .../ssr-preserve-comments/expected-bundle.js | 43 -- test/js/samples/svg-title/expected-bundle.js | 204 ------ test/js/samples/title/expected-bundle.js | 178 ----- .../expected-bundle.js | 422 ------------ .../window-binding-scroll/expected-bundle.js | 235 ------- test/js/update.js | 8 +- test/parser/update.js | 6 +- 49 files changed, 7 insertions(+), 10549 deletions(-) delete mode 100644 test/js/samples/action/expected-bundle.js delete mode 100644 test/js/samples/bind-width-height/expected-bundle.js delete mode 100644 test/js/samples/collapses-text-around-comments/expected-bundle.js delete mode 100644 test/js/samples/component-static-array/expected-bundle.js delete mode 100644 test/js/samples/component-static-immutable/expected-bundle.js delete mode 100644 test/js/samples/component-static-immutable2/expected-bundle.js delete mode 100644 test/js/samples/component-static/expected-bundle.js delete mode 100644 test/js/samples/computed-collapsed-if/expected-bundle.js delete mode 100644 test/js/samples/css-media-query/expected-bundle.js delete mode 100644 test/js/samples/css-shadow-dom-keyframes/expected-bundle.js delete mode 100644 test/js/samples/debug-empty/expected-bundle.js delete mode 100644 test/js/samples/debug-foo-bar-baz-things/expected-bundle.js delete mode 100644 test/js/samples/debug-foo/expected-bundle.js delete mode 100644 test/js/samples/debug-ssr-foo/expected-bundle.js delete mode 100644 test/js/samples/deconflict-builtins/expected-bundle.js delete mode 100644 test/js/samples/deconflict-globals/expected-bundle.js delete mode 100644 test/js/samples/dev-warning-missing-data-computed/expected-bundle.js delete mode 100644 test/js/samples/do-use-dataset/expected-bundle.js delete mode 100644 test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js delete mode 100644 test/js/samples/dont-use-dataset-in-svg/expected-bundle.js delete mode 100644 test/js/samples/dynamic-import/expected-bundle.js delete mode 100644 test/js/samples/each-block-changed-check/expected-bundle.js delete mode 100644 test/js/samples/each-block-keyed-animated/expected-bundle.js delete mode 100644 test/js/samples/each-block-keyed/expected-bundle.js delete mode 100644 test/js/samples/event-handlers-custom/expected-bundle.js delete mode 100644 test/js/samples/head-no-whitespace/expected-bundle.js delete mode 100644 test/js/samples/if-block-no-update/expected-bundle.js delete mode 100644 test/js/samples/if-block-simple/expected-bundle.js delete mode 100644 test/js/samples/inline-style-optimized-multiple/expected-bundle.js delete mode 100644 test/js/samples/inline-style-optimized-url/expected-bundle.js delete mode 100644 test/js/samples/inline-style-optimized/expected-bundle.js delete mode 100644 test/js/samples/inline-style-unoptimized/expected-bundle.js delete mode 100644 test/js/samples/input-files/expected-bundle.js delete mode 100644 test/js/samples/input-range/expected-bundle.js delete mode 100644 test/js/samples/input-without-blowback-guard/expected-bundle.js delete mode 100644 test/js/samples/legacy-input-type/expected-bundle.js delete mode 100644 test/js/samples/media-bindings/expected-bundle.js delete mode 100644 test/js/samples/non-imported-component/expected-bundle.js delete mode 100644 test/js/samples/select-dynamic-value/expected-bundle.js delete mode 100644 test/js/samples/setup-method/expected-bundle.js delete mode 100644 test/js/samples/ssr-no-oncreate-etc/expected-bundle.js delete mode 100644 test/js/samples/ssr-preserve-comments/expected-bundle.js delete mode 100644 test/js/samples/svg-title/expected-bundle.js delete mode 100644 test/js/samples/title/expected-bundle.js delete mode 100644 test/js/samples/use-elements-as-anchors/expected-bundle.js delete mode 100644 test/js/samples/window-binding-scroll/expected-bundle.js diff --git a/test/js/index.js b/test/js/index.js index 8c6104fa37..e9da9bb91e 100644 --- a/test/js/index.js +++ b/test/js/index.js @@ -37,43 +37,6 @@ describe("js", () => { const output = `${dir}/_actual.js`; fs.writeFileSync(output, actual); - - return rollup({ - input: output, - plugins: [ - { - resolveId(importee, importer) { - if (!importer) return importee; - if (importee === "svelte/shared.js") - return path.resolve("shared.js"); - return null; - } - } - ] - }).then(bundle => { - return bundle.generate({ format: "es" }); - }).then(({ code }) => { - fs.writeFileSync(`${dir}/_actual-bundle.js`, code); - - const expected = fs.readFileSync(`${dir}/expected.js`, "utf-8"); - const expectedBundle = fs.readFileSync( - `${dir}/expected-bundle.js`, - "utf-8" - ); - - assert.equal( - actual.trim().replace(/^[ \t]+$/gm, ""), - expected.trim().replace(/^[ \t]+$/gm, "") - ); - - assert.equal( - code.trim().replace(/^[ \t]+$/gm, ""), - expectedBundle.trim().replace(/^[ \t]+$/gm, "") - ); - }).catch(err => { - if (err.start) console.error(err.start); - throw err; - }); }); }); }); diff --git a/test/js/samples/action/expected-bundle.js b/test/js/samples/action/expected-bundle.js deleted file mode 100644 index 62c04649ec..0000000000 --- a/test/js/samples/action/expected-bundle.js +++ /dev/null @@ -1,212 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function link(node) { - - function onClick(event) { - event.preventDefault(); - history.pushState(null, null, event.target.href); - } - - node.addEventListener('click', onClick); - - return { - destroy() { - node.removeEventListener('click', onClick); - } - } -} -function create_main_fragment(component, ctx) { - var a, link_action; - - return { - c() { - a = createElement("a"); - a.textContent = "Test"; - a.href = "#"; - }, - - m(target, anchor) { - insert(target, a, anchor); - link_action = link.call(component, a) || {}; - }, - - p: noop, - - d(detach) { - if (detach) { - detachNode(a); - } - - if (typeof link_action.destroy === 'function') link_action.destroy.call(component); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/bind-width-height/expected-bundle.js b/test/js/samples/bind-width-height/expected-bundle.js deleted file mode 100644 index a4c740e120..0000000000 --- a/test/js/samples/bind-width-height/expected-bundle.js +++ /dev/null @@ -1,235 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function addResizeListener(element, fn) { - if (getComputedStyle(element).position === 'static') { - element.style.position = 'relative'; - } - - const object = document.createElement('object'); - 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'; - - let win; - - object.onload = () => { - win = object.contentDocument.defaultView; - win.addEventListener('resize', fn); - }; - - if (/Trident/.test(navigator.userAgent)) { - element.appendChild(object); - object.data = 'about:blank'; - } else { - object.data = 'about:blank'; - element.appendChild(object); - } - - return { - cancel: () => { - win && win.removeEventListener && win.removeEventListener('resize', fn); - element.removeChild(object); - } - }; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var div, div_resize_listener; - - function div_resize_handler() { - component.set({ w: div.offsetWidth, h: div.offsetHeight }); - } - - return { - c() { - div = createElement("div"); - div.textContent = "some content"; - component.root._beforecreate.push(div_resize_handler); - }, - - m(target, anchor) { - insert(target, div, anchor); - div_resize_listener = addResizeListener(div, div_resize_handler); - }, - - p: noop, - - d(detach) { - if (detach) { - detachNode(div); - } - - div_resize_listener.cancel(); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - flush(this); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle.js b/test/js/samples/collapses-text-around-comments/expected-bundle.js deleted file mode 100644 index 3f0faa13fc..0000000000 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ /dev/null @@ -1,223 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function setData(text, data) { - text.data = '' + data; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function data() { - return { foo: 42 } -} -function add_css() { - var style = createElement("style"); - style.id = 'svelte-1a7i8ec-style'; - style.textContent = "p.svelte-1a7i8ec{color:red}"; - append(document.head, style); -} - -function create_main_fragment(component, ctx) { - var p, text; - - return { - c() { - p = createElement("p"); - text = createText(ctx.foo); - p.className = "svelte-1a7i8ec"; - }, - - m(target, anchor) { - insert(target, p, anchor); - append(p, text); - }, - - p(changed, ctx) { - if (changed.foo) { - setData(text, ctx.foo); - } - }, - - d(detach) { - if (detach) { - detachNode(p); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign(data(), options.data); - this._intro = true; - - if (!document.getElementById("svelte-1a7i8ec-style")) add_css(); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/component-static-array/expected-bundle.js b/test/js/samples/component-static-array/expected-bundle.js deleted file mode 100644 index c2f94398c0..0000000000 --- a/test/js/samples/component-static-array/expected-bundle.js +++ /dev/null @@ -1,188 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -var Nested = window.Nested; - -function create_main_fragment(component, ctx) { - - var nested_initial_data = { foo: [1, 2, 3] }; - var nested = new Nested({ - root: component.root, - store: component.store, - data: nested_initial_data - }); - - return { - c() { - nested._fragment.c(); - }, - - m(target, anchor) { - nested._mount(target, anchor); - }, - - p: noop, - - d(detach) { - nested.destroy(detach); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - flush(this); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js deleted file mode 100644 index ac9ae4d3f6..0000000000 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ /dev/null @@ -1,194 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function _differsImmutable(a, b) { - return a != a ? b == b : a !== b; -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -var Nested = window.Nested; - -function create_main_fragment(component, ctx) { - - var nested_initial_data = { foo: "bar" }; - var nested = new Nested({ - root: component.root, - store: component.store, - data: nested_initial_data - }); - - return { - c() { - nested._fragment.c(); - }, - - m(target, anchor) { - nested._mount(target, anchor); - }, - - p: noop, - - d(detach) { - nested.destroy(detach); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - flush(this); - } -} - -assign(SvelteComponent.prototype, proto); - -SvelteComponent.prototype._differs = _differsImmutable; - -export default SvelteComponent; diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js deleted file mode 100644 index ac9ae4d3f6..0000000000 --- a/test/js/samples/component-static-immutable2/expected-bundle.js +++ /dev/null @@ -1,194 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function _differsImmutable(a, b) { - return a != a ? b == b : a !== b; -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -var Nested = window.Nested; - -function create_main_fragment(component, ctx) { - - var nested_initial_data = { foo: "bar" }; - var nested = new Nested({ - root: component.root, - store: component.store, - data: nested_initial_data - }); - - return { - c() { - nested._fragment.c(); - }, - - m(target, anchor) { - nested._mount(target, anchor); - }, - - p: noop, - - d(detach) { - nested.destroy(detach); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - flush(this); - } -} - -assign(SvelteComponent.prototype, proto); - -SvelteComponent.prototype._differs = _differsImmutable; - -export default SvelteComponent; diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js deleted file mode 100644 index c839759ecf..0000000000 --- a/test/js/samples/component-static/expected-bundle.js +++ /dev/null @@ -1,188 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -var Nested = window.Nested; - -function create_main_fragment(component, ctx) { - - var nested_initial_data = { foo: "bar" }; - var nested = new Nested({ - root: component.root, - store: component.store, - data: nested_initial_data - }); - - return { - c() { - nested._fragment.c(); - }, - - m(target, anchor) { - nested._mount(target, anchor); - }, - - p: noop, - - d(detach) { - nested.destroy(detach); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - flush(this); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js deleted file mode 100644 index c00e61971d..0000000000 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ /dev/null @@ -1,187 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function a({ x }) { - return x * 2; -} - -function b({ x }) { - return x * 3; -} - -function create_main_fragment(component, ctx) { - - return { - c: noop, - - m: noop, - - p: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._recompute({ x: 1 }, this._state); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -SvelteComponent.prototype._recompute = function _recompute(changed, state) { - if (changed.x) { - if (this._differs(state.a, (state.a = a(state)))) changed.a = true; - if (this._differs(state.b, (state.b = b(state)))) changed.b = true; - } -}; - -export default SvelteComponent; diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js deleted file mode 100644 index 80d50457d9..0000000000 --- a/test/js/samples/css-media-query/expected-bundle.js +++ /dev/null @@ -1,206 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function add_css() { - var style = createElement("style"); - style.id = 'svelte-1slhpfn-style'; - style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"; - append(document.head, style); -} - -function create_main_fragment(component, ctx) { - var div; - - return { - c() { - div = createElement("div"); - div.className = "svelte-1slhpfn"; - }, - - m(target, anchor) { - insert(target, div, anchor); - }, - - p: noop, - - d(detach) { - if (detach) { - detachNode(div); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - if (!document.getElementById("svelte-1slhpfn-style")) add_css(); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js deleted file mode 100644 index fb563a9db5..0000000000 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ /dev/null @@ -1,215 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var div; - - return { - c() { - div = createElement("div"); - div.textContent = "fades in"; - this.c = noop; - }, - - m(target, anchor) { - insert(target, div, anchor); - }, - - p: noop, - - d(detach) { - if (detach) { - detachNode(div); - } - } - }; -} - -class SvelteComponent extends HTMLElement { - constructor(options = {}) { - super(); - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this.attachShadow({ mode: 'open' }); - this.shadowRoot.innerHTML = ``; - - this._fragment = create_main_fragment(this, this._state); - - this._fragment.c(); - this._fragment.m(this.shadowRoot, null); - - if (options.target) this._mount(options.target, options.anchor); - } - - static get observedAttributes() { - return []; - } - - attributeChangedCallback(attr, oldValue, newValue) { - this.set({ [attr]: newValue }); - } -} - -assign(SvelteComponent.prototype, proto); -assign(SvelteComponent.prototype, { - _mount(target, anchor) { - target.insertBefore(this, anchor); - } -}); - -customElements.define("custom-element", SvelteComponent); - -export default SvelteComponent; diff --git a/test/js/samples/debug-empty/expected-bundle.js b/test/js/samples/debug-empty/expected-bundle.js deleted file mode 100644 index c4bf667b38..0000000000 --- a/test/js/samples/debug-empty/expected-bundle.js +++ /dev/null @@ -1,254 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function addLoc(element, file, line, column, char) { - element.__svelte_meta = { - loc: { file, line, column, char } - }; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function setData(text, data) { - text.data = '' + data; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function destroyDev(detach) { - destroy.call(this, detach); - this.destroy = function() { - console.warn('Component was already destroyed'); - }; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function setDev(newState) { - if (typeof newState !== 'object') { - throw new Error( - this._debugName + '.set was called without an object of data key-values to update.' - ); - } - - this._checkReadOnly(newState); - set.call(this, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var protoDev = { - destroy: destroyDev, - get, - fire, - on, - set: setDev, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -const file = undefined; - -function create_main_fragment(component, ctx) { - var h1, text0, text1, text2, text3; - - return { - c: function create() { - h1 = createElement("h1"); - text0 = createText("Hello "); - text1 = createText(ctx.name); - text2 = createText("!"); - text3 = createText("\n"); - debugger; - addLoc(h1, file, 0, 0, 0); - }, - - m: function mount(target, anchor) { - insert(target, h1, anchor); - append(h1, text0); - append(h1, text1); - append(h1, text2); - insert(target, text3, anchor); - }, - - p: function update(changed, ctx) { - if (changed.name) { - setData(text1, ctx.name); - } - - debugger; - }, - - d: function destroy$$1(detach) { - if (detach) { - detachNode(h1); - detachNode(text3); - } - } - }; -} - -function SvelteComponent(options) { - this._debugName = ''; - if (!options || (!options.target && !options.root)) throw new Error("'target' is a required option"); - init(this, options); - this._state = assign({}, options.data); - if (!('name' in this._state)) console.warn(" was created without expected data property 'name'"); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - 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); - } -} - -assign(SvelteComponent.prototype, protoDev); - -SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) { -}; - -export default SvelteComponent; diff --git a/test/js/samples/debug-foo-bar-baz-things/expected-bundle.js b/test/js/samples/debug-foo-bar-baz-things/expected-bundle.js deleted file mode 100644 index 5b0111a2e4..0000000000 --- a/test/js/samples/debug-foo-bar-baz-things/expected-bundle.js +++ /dev/null @@ -1,350 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function addLoc(element, file, line, column, char) { - element.__svelte_meta = { - loc: { file, line, column, char } - }; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function destroyEach(iterations, detach) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(detach); - } -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function setData(text, data) { - text.data = '' + data; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function destroyDev(detach) { - destroy.call(this, detach); - this.destroy = function() { - console.warn('Component was already destroyed'); - }; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function setDev(newState) { - if (typeof newState !== 'object') { - throw new Error( - this._debugName + '.set was called without an object of data key-values to update.' - ); - } - - this._checkReadOnly(newState); - set.call(this, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var protoDev = { - destroy: destroyDev, - get, - fire, - on, - set: setDev, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -const file = undefined; - -function get_each_context(ctx, list, i) { - const child_ctx = Object.create(ctx); - child_ctx.thing = list[i]; - child_ctx.each_value = list; - child_ctx.thing_index = i; - return child_ctx; -} - -function create_main_fragment(component, ctx) { - var text0, p, text1, text2; - - var each_value = ctx.things; - - var each_blocks = []; - - for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, get_each_context(ctx, each_value, i)); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - text0 = createText("\n\n"); - p = createElement("p"); - text1 = createText("foo: "); - text2 = createText(ctx.foo); - addLoc(p, file, 5, 0, 91); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insert(target, text0, anchor); - insert(target, p, anchor); - append(p, text1); - append(p, text2); - }, - - p: function update(changed, ctx) { - if (changed.things) { - each_value = ctx.things; - - for (var i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context(ctx, each_value, i); - - if (each_blocks[i]) { - each_blocks[i].p(changed, child_ctx); - } else { - each_blocks[i] = create_each_block(component, child_ctx); - each_blocks[i].c(); - each_blocks[i].m(text0.parentNode, text0); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].d(1); - } - each_blocks.length = each_value.length; - } - - if (changed.foo) { - setData(text2, ctx.foo); - } - }, - - d: function destroy$$1(detach) { - destroyEach(each_blocks, detach); - - if (detach) { - detachNode(text0); - detachNode(p); - } - } - }; -} - -// (1:0) {#each things as thing} -function create_each_block(component, ctx) { - var span, text0_value = ctx.thing.name, text0, text1; - - return { - c: function create() { - span = createElement("span"); - text0 = createText(text0_value); - text1 = createText("\n\t"); - - { - const { foo, bar, baz, thing } = ctx; - console.log({ foo, bar, baz, thing }); - debugger; - } - addLoc(span, file, 1, 1, 25); - }, - - m: function mount(target, anchor) { - insert(target, span, anchor); - append(span, text0); - insert(target, text1, anchor); - }, - - p: function update(changed, ctx) { - if ((changed.things) && text0_value !== (text0_value = ctx.thing.name)) { - setData(text0, text0_value); - } - - if (changed.foo || changed.bar || changed.baz || changed.things) { - const { foo, bar, baz, thing } = ctx; - console.log({ foo, bar, baz, thing }); - debugger; - } - }, - - d: function destroy$$1(detach) { - if (detach) { - detachNode(span); - detachNode(text1); - } - } - }; -} - -function SvelteComponent(options) { - this._debugName = ''; - if (!options || (!options.target && !options.root)) throw new Error("'target' is a required option"); - init(this, options); - this._state = assign({}, options.data); - if (!('things' in this._state)) console.warn(" was created without expected data property 'things'"); - if (!('foo' in this._state)) console.warn(" was created without expected data property 'foo'"); - if (!('bar' in this._state)) console.warn(" was created without expected data property 'bar'"); - if (!('baz' in this._state)) console.warn(" was created without expected data property 'baz'"); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - 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); - } -} - -assign(SvelteComponent.prototype, protoDev); - -SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) { -}; - -export default SvelteComponent; diff --git a/test/js/samples/debug-foo/expected-bundle.js b/test/js/samples/debug-foo/expected-bundle.js deleted file mode 100644 index f8c5af560b..0000000000 --- a/test/js/samples/debug-foo/expected-bundle.js +++ /dev/null @@ -1,348 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function addLoc(element, file, line, column, char) { - element.__svelte_meta = { - loc: { file, line, column, char } - }; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function destroyEach(iterations, detach) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(detach); - } -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function setData(text, data) { - text.data = '' + data; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function destroyDev(detach) { - destroy.call(this, detach); - this.destroy = function() { - console.warn('Component was already destroyed'); - }; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function setDev(newState) { - if (typeof newState !== 'object') { - throw new Error( - this._debugName + '.set was called without an object of data key-values to update.' - ); - } - - this._checkReadOnly(newState); - set.call(this, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var protoDev = { - destroy: destroyDev, - get, - fire, - on, - set: setDev, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -const file = undefined; - -function get_each_context(ctx, list, i) { - const child_ctx = Object.create(ctx); - child_ctx.thing = list[i]; - child_ctx.each_value = list; - child_ctx.thing_index = i; - return child_ctx; -} - -function create_main_fragment(component, ctx) { - var text0, p, text1, text2; - - var each_value = ctx.things; - - var each_blocks = []; - - for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, get_each_context(ctx, each_value, i)); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - text0 = createText("\n\n"); - p = createElement("p"); - text1 = createText("foo: "); - text2 = createText(ctx.foo); - addLoc(p, file, 5, 0, 74); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insert(target, text0, anchor); - insert(target, p, anchor); - append(p, text1); - append(p, text2); - }, - - p: function update(changed, ctx) { - if (changed.things) { - each_value = ctx.things; - - for (var i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context(ctx, each_value, i); - - if (each_blocks[i]) { - each_blocks[i].p(changed, child_ctx); - } else { - each_blocks[i] = create_each_block(component, child_ctx); - each_blocks[i].c(); - each_blocks[i].m(text0.parentNode, text0); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].d(1); - } - each_blocks.length = each_value.length; - } - - if (changed.foo) { - setData(text2, ctx.foo); - } - }, - - d: function destroy$$1(detach) { - destroyEach(each_blocks, detach); - - if (detach) { - detachNode(text0); - detachNode(p); - } - } - }; -} - -// (1:0) {#each things as thing} -function create_each_block(component, ctx) { - var span, text0_value = ctx.thing.name, text0, text1; - - return { - c: function create() { - span = createElement("span"); - text0 = createText(text0_value); - text1 = createText("\n\t"); - - { - const { foo } = ctx; - console.log({ foo }); - debugger; - } - addLoc(span, file, 1, 1, 25); - }, - - m: function mount(target, anchor) { - insert(target, span, anchor); - append(span, text0); - insert(target, text1, anchor); - }, - - p: function update(changed, ctx) { - if ((changed.things) && text0_value !== (text0_value = ctx.thing.name)) { - setData(text0, text0_value); - } - - if (changed.foo) { - const { foo } = ctx; - console.log({ foo }); - debugger; - } - }, - - d: function destroy$$1(detach) { - if (detach) { - detachNode(span); - detachNode(text1); - } - } - }; -} - -function SvelteComponent(options) { - this._debugName = ''; - if (!options || (!options.target && !options.root)) throw new Error("'target' is a required option"); - init(this, options); - this._state = assign({}, options.data); - if (!('things' in this._state)) console.warn(" was created without expected data property 'things'"); - if (!('foo' in this._state)) console.warn(" was created without expected data property 'foo'"); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - 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); - } -} - -assign(SvelteComponent.prototype, protoDev); - -SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) { -}; - -export default SvelteComponent; diff --git a/test/js/samples/debug-ssr-foo/expected-bundle.js b/test/js/samples/debug-ssr-foo/expected-bundle.js deleted file mode 100644 index dcfc5c6d02..0000000000 --- a/test/js/samples/debug-ssr-foo/expected-bundle.js +++ /dev/null @@ -1,46 +0,0 @@ -var { debug, each, escape } = require("svelte/shared.js"); - -var SvelteComponent = {}; -SvelteComponent.data = function() { - return {}; -}; - -SvelteComponent.render = function(state, options = {}) { - var components = new Set(); - - function addComponent(component) { - components.add(component); - } - - var result = { head: '', addComponent }; - var html = SvelteComponent._render(result, state, options); - - var cssCode = Array.from(components).map(c => c.css && c.css.code).filter(Boolean).join('\n'); - - return { - html, - head: result.head, - css: { code: cssCode, map: null }, - toString() { - return html; - } - }; -}; - -SvelteComponent._render = function(__result, ctx, options) { - __result.addComponent(SvelteComponent); - - ctx = Object.assign({}, ctx); - - return `${ each(ctx.things, item => Object.assign({}, ctx, { thing: item }), ctx => `${escape(ctx.thing.name)} - ${debug(null, 2, 2, { foo: ctx.foo })}`)} - -

foo: ${escape(ctx.foo)}

`; -}; - -SvelteComponent.css = { - code: '', - map: null -}; - -module.exports = SvelteComponent; diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js deleted file mode 100644 index 7523521a4f..0000000000 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ /dev/null @@ -1,290 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function destroyEach(iterations, detach) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(detach); - } -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function createComment() { - return document.createComment(''); -} - -function setData(text, data) { - text.data = '' + data; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function get_each_context(ctx, list, i) { - const child_ctx = Object.create(ctx); - child_ctx.node = list[i]; - child_ctx.each_value = list; - child_ctx.node_index = i; - return child_ctx; -} - -function create_main_fragment(component, ctx) { - var each_anchor; - - var each_value = ctx.createElement; - - var each_blocks = []; - - for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, get_each_context(ctx, each_value, i)); - } - - return { - c() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - each_anchor = createComment(); - }, - - m(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insert(target, each_anchor, anchor); - }, - - p(changed, ctx) { - if (changed.createElement) { - each_value = ctx.createElement; - - for (var i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context(ctx, each_value, i); - - if (each_blocks[i]) { - each_blocks[i].p(changed, child_ctx); - } else { - each_blocks[i] = create_each_block(component, child_ctx); - each_blocks[i].c(); - each_blocks[i].m(each_anchor.parentNode, each_anchor); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].d(1); - } - each_blocks.length = each_value.length; - } - }, - - d(detach) { - destroyEach(each_blocks, detach); - - if (detach) { - detachNode(each_anchor); - } - } - }; -} - -// (1:0) {#each createElement as node} -function create_each_block(component, ctx) { - var span, text_value = ctx.node, text; - - return { - c() { - span = createElement("span"); - text = createText(text_value); - }, - - m(target, anchor) { - insert(target, span, anchor); - append(span, text); - }, - - p(changed, ctx) { - if ((changed.createElement) && text_value !== (text_value = ctx.node)) { - setData(text, text_value); - } - }, - - d(detach) { - if (detach) { - detachNode(span); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js deleted file mode 100644 index 46d2f7bbf8..0000000000 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ /dev/null @@ -1,192 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function assignTrue(tar, src) { - for (var k in src) tar[k] = 1; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function data_1() { - return { - foo: 'bar' -}; -} - -function oncreate() { - alert(JSON.stringify(data())); -} -function create_main_fragment(component, ctx) { - - return { - c: noop, - - m: noop, - - p: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign(data_1(), options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - this.root._oncreate.push(() => { - oncreate.call(this); - this.fire("update", { changed: assignTrue({}, this._state), current: this._state }); - }); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - flush(this); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; 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 deleted file mode 100644 index ebc714d6ca..0000000000 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js +++ /dev/null @@ -1,264 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function addLoc(element, file, line, column, char) { - element.__svelte_meta = { - loc: { file, line, column, char } - }; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function setData(text, data) { - text.data = '' + data; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function destroyDev(detach) { - destroy.call(this, detach); - this.destroy = function() { - console.warn('Component was already destroyed'); - }; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function setDev(newState) { - if (typeof newState !== 'object') { - throw new Error( - this._debugName + '.set was called without an object of data key-values to update.' - ); - } - - this._checkReadOnly(newState); - set.call(this, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var protoDev = { - destroy: destroyDev, - get, - fire, - on, - set: setDev, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function bar({ foo }) { - return foo * 2; -} - -const file = undefined; - -function create_main_fragment(component, ctx) { - var p, text0_value = ctx.Math.max(0, ctx.foo), text0, text1, text2; - - return { - c: function create() { - p = createElement("p"); - text0 = createText(text0_value); - text1 = createText("\n\t"); - text2 = createText(ctx.bar); - addLoc(p, file, 0, 0, 0); - }, - - m: function mount(target, anchor) { - insert(target, p, anchor); - append(p, text0); - append(p, text1); - append(p, text2); - }, - - p: function update(changed, ctx) { - if ((changed.Math || changed.foo) && text0_value !== (text0_value = ctx.Math.max(0, ctx.foo))) { - setData(text0, text0_value); - } - - if (changed.bar) { - setData(text2, ctx.bar); - } - }, - - d: function destroy$$1(detach) { - if (detach) { - detachNode(p); - } - } - }; -} - -function SvelteComponent(options) { - this._debugName = ''; - if (!options || (!options.target && !options.root)) throw new Error("'target' is a required option"); - init(this, options); - this._state = assign({ Math : Math }, options.data); - this._recompute({ foo: 1 }, this._state); - if (!('foo' in this._state)) console.warn(" was created without expected data property 'foo'"); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - 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); - } -} - -assign(SvelteComponent.prototype, protoDev); - -SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) { - if ('bar' in newState && !this._updatingReadonlyProperty) throw new Error(": Cannot set read-only property 'bar'"); -}; - -SvelteComponent.prototype._recompute = function _recompute(changed, state) { - if (changed.foo) { - if (this._differs(state.bar, (state.bar = bar(state)))) changed.bar = true; - } -}; - -export default SvelteComponent; diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js deleted file mode 100644 index 6f4f63468d..0000000000 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ /dev/null @@ -1,208 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var div0, text, div1; - - return { - c() { - div0 = createElement("div"); - text = createText("\n"); - div1 = createElement("div"); - div0.dataset.foo = "bar"; - div1.dataset.foo = ctx.bar; - }, - - m(target, anchor) { - insert(target, div0, anchor); - insert(target, text, anchor); - insert(target, div1, anchor); - }, - - p(changed, ctx) { - if (changed.bar) { - div1.dataset.foo = ctx.bar; - } - }, - - d(detach) { - if (detach) { - detachNode(div0); - detachNode(text); - detachNode(div1); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; 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 deleted file mode 100644 index f6252e7efa..0000000000 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js +++ /dev/null @@ -1,212 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var div0, text, div1; - - return { - c() { - div0 = createElement("div"); - text = createText("\n"); - div1 = createElement("div"); - setAttribute(div0, "data-foo", "bar"); - setAttribute(div1, "data-foo", ctx.bar); - }, - - m(target, anchor) { - insert(target, div0, anchor); - insert(target, text, anchor); - insert(target, div1, anchor); - }, - - p(changed, ctx) { - if (changed.bar) { - setAttribute(div1, "data-foo", ctx.bar); - } - }, - - d(detach) { - if (detach) { - detachNode(div0); - detachNode(text); - detachNode(div1); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; 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 deleted file mode 100644 index 4802a66499..0000000000 --- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js +++ /dev/null @@ -1,210 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createSvgElement(name) { - return document.createElementNS('http://www.w3.org/2000/svg', name); -} - -function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var svg, g0, g1; - - return { - c() { - svg = createSvgElement("svg"); - g0 = createSvgElement("g"); - g1 = createSvgElement("g"); - setAttribute(g0, "data-foo", "bar"); - setAttribute(g1, "data-foo", ctx.bar); - }, - - m(target, anchor) { - insert(target, svg, anchor); - append(svg, g0); - append(svg, g1); - }, - - p(changed, ctx) { - if (changed.bar) { - setAttribute(g1, "data-foo", ctx.bar); - } - }, - - d(detach) { - if (detach) { - detachNode(svg); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/dynamic-import/expected-bundle.js b/test/js/samples/dynamic-import/expected-bundle.js deleted file mode 100644 index 7283c2cf17..0000000000 --- a/test/js/samples/dynamic-import/expected-bundle.js +++ /dev/null @@ -1,186 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - - var lazyload_initial_data = { load: () => import('./Foo.html') }; - var lazyload = new LazyLoad({ - root: component.root, - store: component.store, - data: lazyload_initial_data - }); - - return { - c() { - lazyload._fragment.c(); - }, - - m(target, anchor) { - lazyload._mount(target, anchor); - }, - - p: noop, - - d(detach) { - lazyload.destroy(detach); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - flush(this); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js deleted file mode 100644 index 7cbba98148..0000000000 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ /dev/null @@ -1,331 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function detachAfter(before) { - while (before.nextSibling) { - before.parentNode.removeChild(before.nextSibling); - } -} - -function destroyEach(iterations, detach) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(detach); - } -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function setData(text, data) { - text.data = '' + data; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function get_each_context(ctx, list, i) { - const child_ctx = Object.create(ctx); - child_ctx.comment = list[i]; - child_ctx.each_value = list; - child_ctx.i = i; - return child_ctx; -} - -function create_main_fragment(component, ctx) { - var text0, p, text1; - - var each_value = ctx.comments; - - var each_blocks = []; - - for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, get_each_context(ctx, each_value, i)); - } - - return { - c() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - text0 = createText("\n\n"); - p = createElement("p"); - text1 = createText(ctx.foo); - }, - - m(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insert(target, text0, anchor); - insert(target, p, anchor); - append(p, text1); - }, - - p(changed, ctx) { - if (changed.comments || changed.elapsed || changed.time) { - each_value = ctx.comments; - - for (var i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context(ctx, each_value, i); - - if (each_blocks[i]) { - each_blocks[i].p(changed, child_ctx); - } else { - each_blocks[i] = create_each_block(component, child_ctx); - each_blocks[i].c(); - each_blocks[i].m(text0.parentNode, text0); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].d(1); - } - each_blocks.length = each_value.length; - } - - if (changed.foo) { - setData(text1, ctx.foo); - } - }, - - d(detach) { - destroyEach(each_blocks, detach); - - if (detach) { - detachNode(text0); - detachNode(p); - } - } - }; -} - -// (1:0) {#each comments as comment, i} -function create_each_block(component, ctx) { - var div, strong, text0, text1, span, text2_value = ctx.comment.author, text2, text3, text4_value = ctx.elapsed(ctx.comment.time, ctx.time), text4, text5, text6, raw_value = ctx.comment.html, raw_before; - - return { - c() { - div = createElement("div"); - strong = createElement("strong"); - text0 = createText(ctx.i); - text1 = createText("\n\n\t\t"); - span = createElement("span"); - text2 = createText(text2_value); - text3 = createText(" wrote "); - text4 = createText(text4_value); - text5 = createText(" ago:"); - text6 = createText("\n\n\t\t"); - raw_before = createElement('noscript'); - span.className = "meta"; - div.className = "comment"; - }, - - m(target, anchor) { - insert(target, div, anchor); - append(div, strong); - append(strong, text0); - append(div, text1); - append(div, span); - append(span, text2); - append(span, text3); - append(span, text4); - append(span, text5); - append(div, text6); - append(div, raw_before); - raw_before.insertAdjacentHTML("afterend", raw_value); - }, - - p(changed, ctx) { - if ((changed.comments) && text2_value !== (text2_value = ctx.comment.author)) { - setData(text2, text2_value); - } - - if ((changed.elapsed || changed.comments || changed.time) && text4_value !== (text4_value = ctx.elapsed(ctx.comment.time, ctx.time))) { - setData(text4, text4_value); - } - - if ((changed.comments) && raw_value !== (raw_value = ctx.comment.html)) { - detachAfter(raw_before); - raw_before.insertAdjacentHTML("afterend", raw_value); - } - }, - - d(detach) { - if (detach) { - detachNode(div); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/each-block-keyed-animated/expected-bundle.js b/test/js/samples/each-block-keyed-animated/expected-bundle.js deleted file mode 100644 index bc77cc696e..0000000000 --- a/test/js/samples/each-block-keyed-animated/expected-bundle.js +++ /dev/null @@ -1,609 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function createComment() { - return document.createComment(''); -} - -function setData(text, data) { - text.data = '' + data; -} - -function linear(t) { - return t; -} - -function generateRule({ a, b, delta, duration }, ease, fn) { - const step = 16.666 / duration; - let keyframes = '{\n'; - - for (let p = 0; p <= 1; p += step) { - const t = a + delta * ease(p); - keyframes += p * 100 + `%{${fn(t, 1 - t)}}\n`; - } - - return keyframes + `100% {${fn(b, 1 - b)}}\n}`; -} - -// https://github.com/darkskyapp/string-hash/blob/master/index.js -function hash(str) { - let hash = 5381; - let i = str.length; - - while (i--) hash = ((hash << 5) - hash) ^ str.charCodeAt(i); - return hash >>> 0; -} - -var transitionManager = { - running: false, - transitions: [], - bound: null, - stylesheet: null, - activeRules: {}, - promise: null, - - add(transition) { - this.transitions.push(transition); - - if (!this.running) { - this.running = true; - requestAnimationFrame(this.bound || (this.bound = this.next.bind(this))); - } - }, - - addRule(rule, name) { - if (!this.stylesheet) { - const style = createElement('style'); - document.head.appendChild(style); - transitionManager.stylesheet = style.sheet; - } - - if (!this.activeRules[name]) { - this.activeRules[name] = true; - this.stylesheet.insertRule(`@keyframes ${name} ${rule}`, this.stylesheet.cssRules.length); - } - }, - - next() { - this.running = false; - - const now = window.performance.now(); - let i = this.transitions.length; - - while (i--) { - const transition = this.transitions[i]; - - if (transition.program && now >= transition.program.end) { - transition.done(); - } - - if (transition.pending && now >= transition.pending.start) { - transition.start(transition.pending); - } - - if (transition.running) { - transition.update(now); - this.running = true; - } else if (!transition.pending) { - this.transitions.splice(i, 1); - } - } - - if (this.running) { - requestAnimationFrame(this.bound); - } else if (this.stylesheet) { - let i = this.stylesheet.cssRules.length; - while (i--) this.stylesheet.deleteRule(i); - this.activeRules = {}; - } - }, - - deleteRule(node, name) { - node.style.animation = node.style.animation - .split(', ') - .filter(anim => anim && anim.indexOf(name) === -1) - .join(', '); - }, - - wait() { - if (!transitionManager.promise) { - transitionManager.promise = Promise.resolve(); - transitionManager.promise.then(() => { - transitionManager.promise = null; - }); - } - - return transitionManager.promise; - } -}; - -function wrapAnimation(node, from, fn, params) { - if (!from) return; - - const to = node.getBoundingClientRect(); - if (from.left === to.left && from.right === to.right && from.top === to.top && from.bottom === to.bottom) return; - - const info = fn(node, { from, to }, params); - - const duration = 'duration' in info ? info.duration : 300; - const delay = 'delay' in info ? info.delay : 0; - const ease = info.easing || linear; - const start = window.performance.now() + delay; - const end = start + duration; - - const program = { - a: 0, - t: 0, - b: 1, - delta: 1, - duration, - start, - end - }; - - const cssText = node.style.cssText; - - const animation = { - pending: delay ? program : null, - program: delay ? null : program, - running: true, - - start() { - if (info.css) { - if (delay) node.style.cssText = cssText; - - const rule = generateRule(program, ease, info.css); - program.name = `__svelte_${hash(rule)}`; - - transitionManager.addRule(rule, program.name); - - node.style.animation = (node.style.animation || '') - .split(', ') - .filter(anim => anim && (program.delta < 0 || !/__svelte/.test(anim))) - .concat(`${program.name} ${program.duration}ms linear 1 forwards`) - .join(', '); - } - - animation.program = program; - animation.pending = null; - }, - - update: now => { - const p = now - program.start; - const t = program.a + program.delta * ease(p / program.duration); - if (info.tick) info.tick(t, 1 - t); - }, - - done() { - if (info.tick) info.tick(1, 0); - animation.stop(); - }, - - stop() { - if (info.css) transitionManager.deleteRule(node, program.name); - animation.running = false; - } - }; - - transitionManager.add(animation); - - if (info.tick) info.tick(0, 1); - - if (delay) { - if (info.css) node.style.cssText += info.css(0, 1); - } else { - animation.start(); - } - - return animation; -} - -function fixPosition(node) { - const style = getComputedStyle(node); - - if (style.position !== 'absolute' && style.position !== 'fixed') { - const { width, height } = style; - const a = node.getBoundingClientRect(); - node.style.position = 'absolute'; - node.style.width = width; - node.style.height = height; - const b = node.getBoundingClientRect(); - - if (a.left !== b.left || a.top !== b.top) { - const style = getComputedStyle(node); - const transform = style.transform === 'none' ? '' : style.transform; - - node.style.transform = `${transform} translate(${a.left - b.left}px, ${a.top - b.top}px)`; - } - } -} - -function destroyBlock(block, lookup) { - block.d(1); - lookup[block.key] = null; -} - -function outroAndDestroyBlock(block, lookup) { - block.o(function() { - destroyBlock(block, lookup); - }); -} - -function fixAndOutroAndDestroyBlock(block, lookup) { - block.f(); - outroAndDestroyBlock(block, lookup); -} - -function updateKeyedEach(old_blocks, component, changed, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, intro_method, next, get_context) { - var o = old_blocks.length; - var n = list.length; - - var i = o; - var old_indexes = {}; - while (i--) old_indexes[old_blocks[i].key] = i; - - var new_blocks = []; - var new_lookup = {}; - var deltas = {}; - - var i = n; - while (i--) { - var child_ctx = get_context(ctx, list, i); - var key = get_key(child_ctx); - var block = lookup[key]; - - if (!block) { - block = create_each_block(component, key, child_ctx); - block.c(); - } else if (dynamic) { - block.p(changed, child_ctx); - } - - new_blocks[i] = new_lookup[key] = block; - - if (key in old_indexes) deltas[key] = Math.abs(i - old_indexes[key]); - } - - var will_move = {}; - var did_move = {}; - - function insert(block) { - block[intro_method](node, next); - lookup[block.key] = block; - next = block.first; - n--; - } - - while (o && n) { - var new_block = new_blocks[n - 1]; - var old_block = old_blocks[o - 1]; - var new_key = new_block.key; - var old_key = old_block.key; - - if (new_block === old_block) { - // do nothing - next = new_block.first; - o--; - n--; - } - - else if (!new_lookup[old_key]) { - // remove old block - destroy(old_block, lookup); - o--; - } - - else if (!lookup[new_key] || will_move[new_key]) { - insert(new_block); - } - - else if (did_move[old_key]) { - o--; - - } else if (deltas[new_key] > deltas[old_key]) { - did_move[new_key] = true; - insert(new_block); - - } else { - will_move[old_key] = true; - o--; - } - } - - while (o--) { - var old_block = old_blocks[o]; - if (!new_lookup[old_block.key]) destroy(old_block, lookup); - } - - while (n) insert(new_blocks[n - 1]); - - return new_blocks; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function foo(node, animation, params) { - const dx = animation.from.left - animation.to.left; - const dy = animation.from.top - animation.to.top; - - return { - delay: params.delay, - duration: 100, - tick: (t, u) => { - node.dx = u * dx; - node.dy = u * dy; - } - }; -} -function get_each_context(ctx, list, i) { - const child_ctx = Object.create(ctx); - child_ctx.thing = list[i]; - child_ctx.each_value = list; - child_ctx.thing_index = i; - return child_ctx; -} - -function create_main_fragment(component, ctx) { - var each_blocks_1 = [], each_lookup = blankObject(), each_anchor; - - var each_value = ctx.things; - - const get_key = ctx => ctx.thing.id; - - for (var i = 0; i < each_value.length; i += 1) { - let child_ctx = get_each_context(ctx, each_value, i); - let key = get_key(child_ctx); - each_blocks_1[i] = each_lookup[key] = create_each_block(component, key, child_ctx); - } - - return { - c() { - for (i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].c(); - - each_anchor = createComment(); - }, - - m(target, anchor) { - for (i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].m(target, anchor); - - insert(target, each_anchor, anchor); - }, - - p(changed, ctx) { - const each_value = ctx.things; - for (let i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].r(); - each_blocks_1 = updateKeyedEach(each_blocks_1, component, changed, get_key, 1, ctx, each_value, each_lookup, each_anchor.parentNode, fixAndOutroAndDestroyBlock, create_each_block, "m", each_anchor, get_each_context); - for (let i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].a(); - }, - - d(detach) { - for (i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].d(detach); - - if (detach) { - detachNode(each_anchor); - } - } - }; -} - -// (1:0) {#each things as thing (thing.id)} -function create_each_block(component, key_1, ctx) { - var div, text_value = ctx.thing.name, text, rect, animation; - - return { - key: key_1, - - first: null, - - c() { - div = createElement("div"); - text = createText(text_value); - this.first = div; - }, - - m(target, anchor) { - insert(target, div, anchor); - append(div, text); - }, - - p(changed, ctx) { - if ((changed.things) && text_value !== (text_value = ctx.thing.name)) { - setData(text, text_value); - } - }, - - r() { - rect = div.getBoundingClientRect(); - }, - - f() { - fixPosition(div); - if (animation) animation.stop(); - }, - - a() { - if (animation) animation.stop(); - animation = wrapAnimation(div, rect, foo, {}); - }, - - d(detach) { - if (detach) { - detachNode(div); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/each-block-keyed/expected-bundle.js b/test/js/samples/each-block-keyed/expected-bundle.js deleted file mode 100644 index dc38671788..0000000000 --- a/test/js/samples/each-block-keyed/expected-bundle.js +++ /dev/null @@ -1,360 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function createComment() { - return document.createComment(''); -} - -function setData(text, data) { - text.data = '' + data; -} - -function destroyBlock(block, lookup) { - block.d(1); - lookup[block.key] = null; -} - -function updateKeyedEach(old_blocks, component, changed, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, intro_method, next, get_context) { - var o = old_blocks.length; - var n = list.length; - - var i = o; - var old_indexes = {}; - while (i--) old_indexes[old_blocks[i].key] = i; - - var new_blocks = []; - var new_lookup = {}; - var deltas = {}; - - var i = n; - while (i--) { - var child_ctx = get_context(ctx, list, i); - var key = get_key(child_ctx); - var block = lookup[key]; - - if (!block) { - block = create_each_block(component, key, child_ctx); - block.c(); - } else if (dynamic) { - block.p(changed, child_ctx); - } - - new_blocks[i] = new_lookup[key] = block; - - if (key in old_indexes) deltas[key] = Math.abs(i - old_indexes[key]); - } - - var will_move = {}; - var did_move = {}; - - function insert(block) { - block[intro_method](node, next); - lookup[block.key] = block; - next = block.first; - n--; - } - - while (o && n) { - var new_block = new_blocks[n - 1]; - var old_block = old_blocks[o - 1]; - var new_key = new_block.key; - var old_key = old_block.key; - - if (new_block === old_block) { - // do nothing - next = new_block.first; - o--; - n--; - } - - else if (!new_lookup[old_key]) { - // remove old block - destroy(old_block, lookup); - o--; - } - - else if (!lookup[new_key] || will_move[new_key]) { - insert(new_block); - } - - else if (did_move[old_key]) { - o--; - - } else if (deltas[new_key] > deltas[old_key]) { - did_move[new_key] = true; - insert(new_block); - - } else { - will_move[old_key] = true; - o--; - } - } - - while (o--) { - var old_block = old_blocks[o]; - if (!new_lookup[old_block.key]) destroy(old_block, lookup); - } - - while (n) insert(new_blocks[n - 1]); - - return new_blocks; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function get_each_context(ctx, list, i) { - const child_ctx = Object.create(ctx); - child_ctx.thing = list[i]; - child_ctx.each_value = list; - child_ctx.thing_index = i; - return child_ctx; -} - -function create_main_fragment(component, ctx) { - var each_blocks_1 = [], each_lookup = blankObject(), each_anchor; - - var each_value = ctx.things; - - const get_key = ctx => ctx.thing.id; - - for (var i = 0; i < each_value.length; i += 1) { - let child_ctx = get_each_context(ctx, each_value, i); - let key = get_key(child_ctx); - each_blocks_1[i] = each_lookup[key] = create_each_block(component, key, child_ctx); - } - - return { - c() { - for (i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].c(); - - each_anchor = createComment(); - }, - - m(target, anchor) { - for (i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].m(target, anchor); - - insert(target, each_anchor, anchor); - }, - - p(changed, ctx) { - const each_value = ctx.things; - each_blocks_1 = updateKeyedEach(each_blocks_1, component, changed, get_key, 1, ctx, each_value, each_lookup, each_anchor.parentNode, destroyBlock, create_each_block, "m", each_anchor, get_each_context); - }, - - d(detach) { - for (i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].d(detach); - - if (detach) { - detachNode(each_anchor); - } - } - }; -} - -// (1:0) {#each things as thing (thing.id)} -function create_each_block(component, key_1, ctx) { - var div, text_value = ctx.thing.name, text; - - return { - key: key_1, - - first: null, - - c() { - div = createElement("div"); - text = createText(text_value); - this.first = div; - }, - - m(target, anchor) { - insert(target, div, anchor); - append(div, text); - }, - - p(changed, ctx) { - if ((changed.things) && text_value !== (text_value = ctx.thing.name)) { - setData(text, text_value); - } - }, - - d(detach) { - if (detach) { - detachNode(div); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js deleted file mode 100644 index ea4b323271..0000000000 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ /dev/null @@ -1,211 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function foo( node, callback ) { - // code goes here -} -var methods = { - foo ( bar ) { - console.log( bar ); - } -}; - -function create_main_fragment(component, ctx) { - var button, foo_handler; - - return { - c() { - button = createElement("button"); - button.textContent = "foo"; - foo_handler = foo.call(component, button, function(event) { - component.foo( ctx.bar ); - }); - }, - - m(target, anchor) { - insert(target, button, anchor); - }, - - p(changed, _ctx) { - ctx = _ctx; - - }, - - d(detach) { - if (detach) { - detachNode(button); - } - - foo_handler.destroy(); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -assign(SvelteComponent.prototype, methods); - -export default SvelteComponent; diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js deleted file mode 100644 index 1587b2c2ac..0000000000 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ /dev/null @@ -1,197 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var meta0, meta1; - - return { - c() { - meta0 = createElement("meta"); - meta1 = createElement("meta"); - meta0.name = "twitter:creator"; - meta0.content = "@sveltejs"; - meta1.name = "twitter:title"; - meta1.content = "Svelte"; - }, - - m(target, anchor) { - append(document.head, meta0); - append(document.head, meta1); - }, - - p: noop, - - d(detach) { - detachNode(meta0); - detachNode(meta1); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js deleted file mode 100644 index dbd02ccaff..0000000000 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ /dev/null @@ -1,258 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var if_block_anchor; - - function select_block_type(ctx) { - if (ctx.foo) return create_if_block; - return create_else_block; - } - - var current_block_type = select_block_type(ctx); - var if_block = current_block_type(component, ctx); - - return { - c() { - if_block.c(); - if_block_anchor = createComment(); - }, - - m(target, anchor) { - if_block.m(target, anchor); - insert(target, if_block_anchor, anchor); - }, - - p(changed, ctx) { - if (current_block_type !== (current_block_type = select_block_type(ctx))) { - if_block.d(1); - if_block = current_block_type(component, ctx); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - }, - - d(detach) { - if_block.d(detach); - if (detach) { - detachNode(if_block_anchor); - } - } - }; -} - -// (3:0) {:else} -function create_else_block(component, ctx) { - var p; - - return { - c() { - p = createElement("p"); - p.textContent = "not foo!"; - }, - - m(target, anchor) { - insert(target, p, anchor); - }, - - d(detach) { - if (detach) { - detachNode(p); - } - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, ctx) { - var p; - - return { - c() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m(target, anchor) { - insert(target, p, anchor); - }, - - d(detach) { - if (detach) { - detachNode(p); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js deleted file mode 100644 index 2ed0f73584..0000000000 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ /dev/null @@ -1,234 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var if_block_anchor; - - var if_block = (ctx.foo) && create_if_block(component, ctx); - - return { - c() { - if (if_block) if_block.c(); - if_block_anchor = createComment(); - }, - - m(target, anchor) { - if (if_block) if_block.m(target, anchor); - insert(target, if_block_anchor, anchor); - }, - - p(changed, ctx) { - if (ctx.foo) { - if (!if_block) { - if_block = create_if_block(component, ctx); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - } else if (if_block) { - if_block.d(1); - if_block = null; - } - }, - - d(detach) { - if (if_block) if_block.d(detach); - if (detach) { - detachNode(if_block_anchor); - } - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, ctx) { - var p; - - return { - c() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m(target, anchor) { - insert(target, p, anchor); - }, - - d(detach) { - if (detach) { - detachNode(p); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js deleted file mode 100644 index e6ea18a957..0000000000 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ /dev/null @@ -1,206 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -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'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var div; - - return { - c() { - div = createElement("div"); - setStyle(div, "color", ctx.color); - setStyle(div, "transform", "translate(" + ctx.x + "px," + ctx.y + "px)"); - }, - - m(target, anchor) { - insert(target, div, anchor); - }, - - p(changed, ctx) { - if (changed.color) { - setStyle(div, "color", ctx.color); - } - - if (changed.x || changed.y) { - setStyle(div, "transform", "translate(" + ctx.x + "px," + ctx.y + "px)"); - } - }, - - d(detach) { - if (detach) { - detachNode(div); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/inline-style-optimized-url/expected-bundle.js b/test/js/samples/inline-style-optimized-url/expected-bundle.js deleted file mode 100644 index 472c72db8a..0000000000 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ /dev/null @@ -1,201 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -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'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var div; - - return { - c() { - div = createElement("div"); - setStyle(div, "background", "url(data:image/png;base64," + ctx.data + ")"); - }, - - m(target, anchor) { - insert(target, div, anchor); - }, - - p(changed, ctx) { - if (changed.data) { - setStyle(div, "background", "url(data:image/png;base64," + ctx.data + ")"); - } - }, - - d(detach) { - if (detach) { - detachNode(div); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js deleted file mode 100644 index 40425bcc01..0000000000 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ /dev/null @@ -1,201 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -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'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var div; - - return { - c() { - div = createElement("div"); - setStyle(div, "color", ctx.color); - }, - - m(target, anchor) { - insert(target, div, anchor); - }, - - p(changed, ctx) { - if (changed.color) { - setStyle(div, "color", ctx.color); - } - }, - - d(detach) { - if (detach) { - detachNode(div); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js deleted file mode 100644 index 1f0161a616..0000000000 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ /dev/null @@ -1,212 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var div0, text, div1, div1_style_value; - - return { - c() { - div0 = createElement("div"); - text = createText("\n"); - div1 = createElement("div"); - div0.style.cssText = ctx.style; - div1.style.cssText = div1_style_value = "" + ctx.key + ": " + ctx.value; - }, - - m(target, anchor) { - insert(target, div0, anchor); - insert(target, text, anchor); - insert(target, div1, anchor); - }, - - p(changed, ctx) { - if (changed.style) { - div0.style.cssText = ctx.style; - } - - if ((changed.key || changed.value) && div1_style_value !== (div1_style_value = "" + ctx.key + ": " + ctx.value)) { - div1.style.cssText = div1_style_value; - } - }, - - d(detach) { - if (detach) { - detachNode(div0); - detachNode(text); - detachNode(div1); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/input-files/expected-bundle.js b/test/js/samples/input-files/expected-bundle.js deleted file mode 100644 index b598e619ff..0000000000 --- a/test/js/samples/input-files/expected-bundle.js +++ /dev/null @@ -1,219 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function addListener(node, event, handler) { - node.addEventListener(event, handler, false); -} - -function removeListener(node, event, handler) { - node.removeEventListener(event, handler, false); -} - -function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var input, input_updating = false; - - function input_input_handler() { - input_updating = true; - component.set({ files: input.files }); - input_updating = false; - } - - return { - c() { - input = createElement("input"); - addListener(input, "input", input_input_handler); - setAttribute(input, "type", "file"); - input.multiple = true; - }, - - m(target, anchor) { - insert(target, input, anchor); - - input.files = ctx.files; - }, - - p(changed, ctx) { - if (!input_updating && changed.files) input.files = ctx.files; - }, - - d(detach) { - if (detach) { - detachNode(input); - } - - removeListener(input, "input", input_input_handler); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/input-range/expected-bundle.js b/test/js/samples/input-range/expected-bundle.js deleted file mode 100644 index 7141e094a3..0000000000 --- a/test/js/samples/input-range/expected-bundle.js +++ /dev/null @@ -1,222 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function addListener(node, event, handler) { - node.addEventListener(event, handler, false); -} - -function removeListener(node, event, handler) { - node.removeEventListener(event, handler, false); -} - -function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); -} - -function toNumber(value) { - return value === '' ? undefined : +value; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var input; - - function input_change_input_handler() { - component.set({ value: toNumber(input.value) }); - } - - return { - c() { - input = createElement("input"); - addListener(input, "change", input_change_input_handler); - addListener(input, "input", input_change_input_handler); - setAttribute(input, "type", "range"); - }, - - m(target, anchor) { - insert(target, input, anchor); - - input.value = ctx.value; - }, - - p(changed, ctx) { - if (changed.value) input.value = ctx.value; - }, - - d(detach) { - if (detach) { - detachNode(input); - } - - removeListener(input, "change", input_change_input_handler); - removeListener(input, "input", input_change_input_handler); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/input-without-blowback-guard/expected-bundle.js b/test/js/samples/input-without-blowback-guard/expected-bundle.js deleted file mode 100644 index 307545663c..0000000000 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ /dev/null @@ -1,216 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function addListener(node, event, handler) { - node.addEventListener(event, handler, false); -} - -function removeListener(node, event, handler) { - node.removeEventListener(event, handler, false); -} - -function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var input; - - function input_change_handler() { - component.set({ foo: input.checked }); - } - - return { - c() { - input = createElement("input"); - addListener(input, "change", input_change_handler); - setAttribute(input, "type", "checkbox"); - }, - - m(target, anchor) { - insert(target, input, anchor); - - input.checked = ctx.foo; - }, - - p(changed, ctx) { - if (changed.foo) input.checked = ctx.foo; - }, - - d(detach) { - if (detach) { - detachNode(input); - } - - removeListener(input, "change", input_change_handler); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js deleted file mode 100644 index a10dfa137d..0000000000 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ /dev/null @@ -1,199 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function setInputType(input, type) { - try { - input.type = type; - } catch (e) {} -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var input; - - return { - c() { - input = createElement("input"); - setInputType(input, "search"); - }, - - m(target, anchor) { - insert(target, input, anchor); - }, - - p: noop, - - d(detach) { - if (detach) { - detachNode(input); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js deleted file mode 100644 index 33f9f76d09..0000000000 --- a/test/js/samples/media-bindings/expected-bundle.js +++ /dev/null @@ -1,267 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function addListener(node, event, handler) { - node.addEventListener(event, handler, false); -} - -function removeListener(node, event, handler) { - node.removeEventListener(event, handler, false); -} - -function timeRangesToArray(ranges) { - var array = []; - for (var i = 0; i < ranges.length; i += 1) { - array.push({ start: ranges.start(i), end: ranges.end(i) }); - } - return array; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var audio, audio_is_paused = true, audio_updating = false, audio_animationframe; - - function audio_timeupdate_handler() { - cancelAnimationFrame(audio_animationframe); - if (!audio.paused) audio_animationframe = requestAnimationFrame(audio_timeupdate_handler); - audio_updating = true; - component.set({ played: timeRangesToArray(audio.played), currentTime: audio.currentTime }); - audio_updating = false; - } - - function audio_durationchange_handler() { - component.set({ duration: audio.duration }); - } - - function audio_play_pause_handler() { - audio_updating = true; - component.set({ paused: audio.paused }); - audio_updating = false; - } - - function audio_progress_handler() { - component.set({ buffered: timeRangesToArray(audio.buffered) }); - } - - function audio_loadedmetadata_handler() { - component.set({ buffered: timeRangesToArray(audio.buffered), seekable: timeRangesToArray(audio.seekable) }); - } - - function audio_volumechange_handler() { - audio_updating = true; - component.set({ volume: audio.volume }); - audio_updating = false; - } - - return { - c() { - audio = createElement("audio"); - addListener(audio, "timeupdate", audio_timeupdate_handler); - if (!('played' in ctx && 'currentTime' in ctx)) component.root._beforecreate.push(audio_timeupdate_handler); - addListener(audio, "durationchange", audio_durationchange_handler); - if (!('duration' in ctx)) component.root._beforecreate.push(audio_durationchange_handler); - addListener(audio, "play", audio_play_pause_handler); - addListener(audio, "pause", audio_play_pause_handler); - addListener(audio, "progress", audio_progress_handler); - if (!('buffered' in ctx)) component.root._beforecreate.push(audio_progress_handler); - addListener(audio, "loadedmetadata", audio_loadedmetadata_handler); - if (!('buffered' in ctx && 'seekable' in ctx)) component.root._beforecreate.push(audio_loadedmetadata_handler); - addListener(audio, "volumechange", audio_volumechange_handler); - }, - - m(target, anchor) { - insert(target, audio, anchor); - - audio.volume = ctx.volume; - }, - - p(changed, ctx) { - if (!audio_updating && !isNaN(ctx.currentTime ) && changed.currentTime) audio.currentTime = ctx.currentTime ; - if (!audio_updating && audio_is_paused !== (audio_is_paused = ctx.paused ) && changed.paused) audio[audio_is_paused ? "pause" : "play"](); - if (!audio_updating && !isNaN(ctx.volume) && changed.volume) audio.volume = ctx.volume; - }, - - d(detach) { - if (detach) { - detachNode(audio); - } - - removeListener(audio, "timeupdate", audio_timeupdate_handler); - removeListener(audio, "durationchange", audio_durationchange_handler); - removeListener(audio, "play", audio_play_pause_handler); - removeListener(audio, "pause", audio_play_pause_handler); - removeListener(audio, "progress", audio_progress_handler); - removeListener(audio, "loadedmetadata", audio_loadedmetadata_handler); - removeListener(audio, "volumechange", audio_volumechange_handler); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - flush(this); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js deleted file mode 100644 index ec8f608726..0000000000 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ /dev/null @@ -1,215 +0,0 @@ -import Imported from 'Imported.html'; - -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - - - -function create_main_fragment(component, ctx) { - var text; - - var imported = new Imported({ - root: component.root, - store: component.store - }); - - var nonimported = new NonImported({ - root: component.root, - store: component.store - }); - - return { - c() { - imported._fragment.c(); - text = createText("\n"); - nonimported._fragment.c(); - }, - - m(target, anchor) { - imported._mount(target, anchor); - insert(target, text, anchor); - nonimported._mount(target, anchor); - }, - - p: noop, - - d(detach) { - imported.destroy(detach); - if (detach) { - detachNode(text); - } - - nonimported.destroy(detach); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - flush(this); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/select-dynamic-value/expected-bundle.js b/test/js/samples/select-dynamic-value/expected-bundle.js deleted file mode 100644 index 8fb7d5851c..0000000000 --- a/test/js/samples/select-dynamic-value/expected-bundle.js +++ /dev/null @@ -1,227 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var select, option0, option1, select_value_value; - - return { - c() { - select = createElement("select"); - option0 = createElement("option"); - option0.textContent = "1"; - option1 = createElement("option"); - option1.textContent = "2"; - option0.__value = "1"; - option0.value = option0.__value; - option1.__value = "2"; - option1.value = option1.__value; - }, - - m(target, anchor) { - insert(target, select, anchor); - append(select, option0); - append(select, option1); - - select_value_value = ctx.current; - for (var i = 0; i < select.options.length; i += 1) { - var option = select.options[i]; - - if (option.__value === select_value_value) { - option.selected = true; - break; - } - } - }, - - p(changed, ctx) { - if ((changed.current) && select_value_value !== (select_value_value = ctx.current)) { - for (var i = 0; i < select.options.length; i += 1) { - var option = select.options[i]; - - if (option.__value === select_value_value) { - option.selected = true; - break; - } - } - } - }, - - d(detach) { - if (detach) { - detachNode(select); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js deleted file mode 100644 index f36e9584c0..0000000000 --- a/test/js/samples/setup-method/expected-bundle.js +++ /dev/null @@ -1,190 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -var methods = { - foo ( bar ) { - console.log( bar ); - } -}; - -function setup(Component) { - Component.SOME_CONSTANT = 42; - Component.factory = function (target) { - return new Component({ - target: target - }); - }; - Component.prototype.foo( 'baz' ); -} - -function create_main_fragment(component, ctx) { - - return { - c: noop, - - m: noop, - - p: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -assign(SvelteComponent.prototype, methods); - -setup(SvelteComponent); - -export default SvelteComponent; diff --git a/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js b/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js deleted file mode 100644 index e2f68fda3c..0000000000 --- a/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js +++ /dev/null @@ -1,46 +0,0 @@ -function preload(input) { - return output; -} -var SvelteComponent = {}; -SvelteComponent.data = function() { - return {}; -}; - -SvelteComponent.render = function(state, options = {}) { - var components = new Set(); - - function addComponent(component) { - components.add(component); - } - - var result = { head: '', addComponent }; - var html = SvelteComponent._render(result, state, options); - - var cssCode = Array.from(components).map(c => c.css && c.css.code).filter(Boolean).join('\n'); - - return { - html, - head: result.head, - css: { code: cssCode, map: null }, - toString() { - return html; - } - }; -}; - -SvelteComponent._render = function(__result, ctx, options) { - __result.addComponent(SvelteComponent); - - ctx = Object.assign({}, ctx); - - return ``; -}; - -SvelteComponent.css = { - code: '', - map: null -}; - -SvelteComponent.preload = preload; - -module.exports = SvelteComponent; diff --git a/test/js/samples/ssr-preserve-comments/expected-bundle.js b/test/js/samples/ssr-preserve-comments/expected-bundle.js deleted file mode 100644 index 06799a65da..0000000000 --- a/test/js/samples/ssr-preserve-comments/expected-bundle.js +++ /dev/null @@ -1,43 +0,0 @@ -var SvelteComponent = {}; -SvelteComponent.data = function() { - return {}; -}; - -SvelteComponent.render = function(state, options = {}) { - var components = new Set(); - - function addComponent(component) { - components.add(component); - } - - var result = { head: '', addComponent }; - var html = SvelteComponent._render(result, state, options); - - var cssCode = Array.from(components).map(c => c.css && c.css.code).filter(Boolean).join('\n'); - - return { - html, - head: result.head, - css: { code: cssCode, map: null }, - toString() { - return html; - } - }; -}; - -SvelteComponent._render = function(__result, ctx, options) { - __result.addComponent(SvelteComponent); - - ctx = Object.assign({}, ctx); - - return `
content
- -
more content
`; -}; - -SvelteComponent.css = { - code: '', - map: null -}; - -module.exports = SvelteComponent; diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js deleted file mode 100644 index 730857faec..0000000000 --- a/test/js/samples/svg-title/expected-bundle.js +++ /dev/null @@ -1,204 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createSvgElement(name) { - return document.createElementNS('http://www.w3.org/2000/svg', name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var svg, title, text; - - return { - c() { - svg = createSvgElement("svg"); - title = createSvgElement("title"); - text = createText("a title"); - }, - - m(target, anchor) { - insert(target, svg, anchor); - append(svg, title); - append(title, text); - }, - - p: noop, - - d(detach) { - if (detach) { - detachNode(svg); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js deleted file mode 100644 index 096430361e..0000000000 --- a/test/js/samples/title/expected-bundle.js +++ /dev/null @@ -1,178 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var title_value; - - document.title = title_value = "a " + ctx.custom + " title"; - - return { - c: noop, - - m: noop, - - p(changed, ctx) { - if ((changed.custom) && title_value !== (title_value = "a " + ctx.custom + " title")) { - document.title = title_value; - } - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle.js b/test/js/samples/use-elements-as-anchors/expected-bundle.js deleted file mode 100644 index f2a5f5bde2..0000000000 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ /dev/null @@ -1,422 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var div, text0, p0, text2, text3, text4, p1, text6, text7, if_block4_anchor; - - var if_block0 = (ctx.a) && create_if_block_4(component, ctx); - - var if_block1 = (ctx.b) && create_if_block_3(component, ctx); - - var if_block2 = (ctx.c) && create_if_block_2(component, ctx); - - var if_block3 = (ctx.d) && create_if_block_1(component, ctx); - - var if_block4 = (ctx.e) && create_if_block(component, ctx); - - return { - c() { - div = createElement("div"); - if (if_block0) if_block0.c(); - text0 = createText("\n\n\t"); - p0 = createElement("p"); - p0.textContent = "this can be used as an anchor"; - text2 = createText("\n\n\t"); - if (if_block1) if_block1.c(); - text3 = createText("\n\n\t"); - if (if_block2) if_block2.c(); - text4 = createText("\n\n\t"); - p1 = createElement("p"); - p1.textContent = "so can this"; - text6 = createText("\n\n\t"); - if (if_block3) if_block3.c(); - text7 = createText("\n\n"); - if (if_block4) if_block4.c(); - if_block4_anchor = createComment(); - }, - - m(target, anchor) { - insert(target, div, anchor); - if (if_block0) if_block0.m(div, null); - append(div, text0); - append(div, p0); - append(div, text2); - if (if_block1) if_block1.m(div, null); - append(div, text3); - if (if_block2) if_block2.m(div, null); - append(div, text4); - append(div, p1); - append(div, text6); - if (if_block3) if_block3.m(div, null); - insert(target, text7, anchor); - if (if_block4) if_block4.m(target, anchor); - insert(target, if_block4_anchor, anchor); - }, - - p(changed, ctx) { - if (ctx.a) { - if (!if_block0) { - if_block0 = create_if_block_4(component, ctx); - if_block0.c(); - if_block0.m(div, null); - } - } else if (if_block0) { - if_block0.d(1); - if_block0 = null; - } - - if (ctx.b) { - if (!if_block1) { - if_block1 = create_if_block_3(component, ctx); - if_block1.c(); - if_block1.m(div, text3); - } - } else if (if_block1) { - if_block1.d(1); - if_block1 = null; - } - - if (ctx.c) { - if (!if_block2) { - if_block2 = create_if_block_2(component, ctx); - if_block2.c(); - if_block2.m(div, text4); - } - } else if (if_block2) { - if_block2.d(1); - if_block2 = null; - } - - if (ctx.d) { - if (!if_block3) { - if_block3 = create_if_block_1(component, ctx); - if_block3.c(); - if_block3.m(div, null); - } - } else if (if_block3) { - if_block3.d(1); - if_block3 = null; - } - - if (ctx.e) { - if (!if_block4) { - if_block4 = create_if_block(component, ctx); - if_block4.c(); - if_block4.m(if_block4_anchor.parentNode, if_block4_anchor); - } - } else if (if_block4) { - if_block4.d(1); - if_block4 = null; - } - }, - - d(detach) { - if (detach) { - detachNode(div); - } - - if (if_block0) if_block0.d(); - if (if_block1) if_block1.d(); - if (if_block2) if_block2.d(); - if (if_block3) if_block3.d(); - if (detach) { - detachNode(text7); - } - - if (if_block4) if_block4.d(detach); - if (detach) { - detachNode(if_block4_anchor); - } - } - }; -} - -// (2:1) {#if a} -function create_if_block_4(component, ctx) { - var p; - - return { - c() { - p = createElement("p"); - p.textContent = "a"; - }, - - m(target, anchor) { - insert(target, p, anchor); - }, - - d(detach) { - if (detach) { - detachNode(p); - } - } - }; -} - -// (8:1) {#if b} -function create_if_block_3(component, ctx) { - var p; - - return { - c() { - p = createElement("p"); - p.textContent = "b"; - }, - - m(target, anchor) { - insert(target, p, anchor); - }, - - d(detach) { - if (detach) { - detachNode(p); - } - } - }; -} - -// (12:1) {#if c} -function create_if_block_2(component, ctx) { - var p; - - return { - c() { - p = createElement("p"); - p.textContent = "c"; - }, - - m(target, anchor) { - insert(target, p, anchor); - }, - - d(detach) { - if (detach) { - detachNode(p); - } - } - }; -} - -// (18:1) {#if d} -function create_if_block_1(component, ctx) { - var p; - - return { - c() { - p = createElement("p"); - p.textContent = "d"; - }, - - m(target, anchor) { - insert(target, p, anchor); - }, - - d(detach) { - if (detach) { - detachNode(p); - } - } - }; -} - -// (25:0) {#if e} -function create_if_block(component, ctx) { - var p; - - return { - c() { - p = createElement("p"); - p.textContent = "e"; - }, - - m(target, anchor) { - insert(target, p, anchor); - }, - - d(detach) { - if (detach) { - detachNode(p); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js deleted file mode 100644 index 112d3157b8..0000000000 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ /dev/null @@ -1,235 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function append(target, node) { - target.appendChild(node); -} - -function insert(target, node, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function setData(text, data) { - text.data = '' + data; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = noop; - - this._fragment.d(detach !== false); - this._fragment = null; - this._state = {}; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - try { - handler.__calling = true; - handler.call(this, data); - } finally { - handler.__calling = false; - } - } - } -} - -function flush(component) { - component._lock = true; - callAll(component._beforecreate); - callAll(component._oncreate); - callAll(component._aftercreate); - component._lock = false; -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._slots = blankObject(); - component._bind = options._bind; - component._staged = {}; - - component.options = options; - component.root = options.root || component; - component.store = options.store || component.root.store; - - if (!options.root) { - component._beforecreate = []; - component._oncreate = []; - component._aftercreate = []; - } -} - -function on(eventName, handler) { - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - flush(this.root); -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - newState = assign(this._staged, newState); - this._staged = {}; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function _stage(newState) { - assign(this._staged, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _stage, - _mount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, ctx) { - var window_updating = false, clear_window_updating = function() { window_updating = false; }, window_updating_timeout, p, text0, text1; - - function onwindowscroll(event) { - if (window_updating) return; - window_updating = true; - - component.set({ - y: this.pageYOffset - }); - window_updating = false; - } - window.addEventListener("scroll", onwindowscroll); - - component.on("state", ({ changed, current }) => { - if (changed["y"]) { - window_updating = true; - clearTimeout(window_updating_timeout); - window.scrollTo(window.pageXOffset, current["y"]); - window_updating_timeout = setTimeout(clear_window_updating, 100); - } - }); - - return { - c() { - p = createElement("p"); - text0 = createText("scrolled to "); - text1 = createText(ctx.y); - }, - - m(target, anchor) { - insert(target, p, anchor); - append(p, text0); - append(p, text1); - }, - - p(changed, ctx) { - if (changed.y) { - setData(text1, ctx.y); - } - }, - - d(detach) { - window.removeEventListener("scroll", onwindowscroll); - - if (detach) { - detachNode(p); - } - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._state.y = window.pageYOffset; - this._intro = true; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/update.js b/test/js/update.js index d50eb9780e..fa9c834182 100644 --- a/test/js/update.js +++ b/test/js/update.js @@ -1,13 +1,13 @@ -// this file will replace all the expected.js and expected-bundle.js files with -// their _actual equivalents. Only use it when you're sure that you haven't +// this file will replace all the expected.js files with their _actual +// equivalents. Only use it when you're sure that you haven't // broken anything! const fs = require("fs"); const glob = require("tiny-glob/sync.js"); -glob("samples/*/_actual*", { cwd: __dirname }).forEach(file => { +glob("samples/*/_actual.js", { cwd: __dirname }).forEach(file => { const actual = fs.readFileSync(`${__dirname}/${file}`, "utf-8"); fs.writeFileSync( - `${__dirname}/${file.replace("_actual", "expected")}`, + `${__dirname}/${file.replace("_actual.js", "expected.js")}`, actual ); }); diff --git a/test/parser/update.js b/test/parser/update.js index 78aa191b65..0edac895b5 100644 --- a/test/parser/update.js +++ b/test/parser/update.js @@ -1,5 +1,5 @@ -// this file will replace all the expected.js and expected-bundle.js files with -// their _actual equivalents. Only use it when you're sure that you haven't +// this file will replace all the output.json files with their _actual.json +// equivalents. Only use it when you're sure that you haven't // broken anything! const fs = require("fs"); const glob = require("tiny-glob/sync.js"); @@ -7,7 +7,7 @@ const glob = require("tiny-glob/sync.js"); glob("samples/*/_actual.json", { cwd: __dirname }).forEach(file => { const actual = fs.readFileSync(`${__dirname}/${file}`, "utf-8"); fs.writeFileSync( - `${__dirname}/${file.replace("_actual", "output")}`, + `${__dirname}/${file.replace("_actual.json", "output.json")}`, actual ); });