From 470eacf9d4fe2d1889edbe36aac92e9b28d87fe9 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 18:02:39 -0400 Subject: [PATCH 01/40] remove obsolete methods --- src/shared/index.js | 71 +++++++++++---------------------------------- 1 file changed, 17 insertions(+), 54 deletions(-) diff --git a/src/shared/index.js b/src/shared/index.js index 5ec905d29bd8..32b59dfde3e2 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -51,13 +51,8 @@ export function fire(eventName, data) { } } -export function getDev(key) { - if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); - return get.call(this, key); -} - -export function get(key) { - return key ? this._state[key] : this._state; +export function get() { + return this._state; } export function init(component, options) { @@ -69,34 +64,6 @@ export function init(component, options) { component.store = component.root.store || options.store; } -export function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -export function observeDev(key, callback, options) { - console.warn("this.observe(key, (newValue, oldValue) => {...}) is deprecated. Use\n\n // runs before DOM updates\n this.on('state', ({ changed, current, previous }) => {...});\n\n // runs after DOM updates\n this.on('update', ...);\n\n...or add the observe method from the svelte-extras package"); - - var c = (key = '' + key).search(/[.[]/); - if (c > -1) { - var message = - 'The first argument to component.observe(...) must be the name of a top-level property'; - if (c > 0) - message += ", i.e. '" + key.slice(0, c) + "' rather than '" + key + "'"; - - throw new Error(message); - } - - return observe.call(this, key, callback, options); -} - export function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -193,31 +160,27 @@ export function removeFromStore() { } export var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; export var protoDev = { destroy: destroyDev, - get: getDev, - fire: fire, - observe: observeDev, + get, + fire, on: onDev, set: setDev, - teardown: destroyDev, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; From 34d2fbfa58e447a3bcc695a1f5a77841e072152f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 18:04:27 -0400 Subject: [PATCH 02/40] remove ES5 constraint --- src/shared/.eslintrc.json | 2 +- src/shared/_build.js | 7 +--- test/runtime/index.js | 32 ------------------- .../samples/binding-indirect/_config.js | 1 - .../samples/function-in-expression/_config.js | 2 -- test/store/index.js | 17 ---------- 6 files changed, 2 insertions(+), 59 deletions(-) diff --git a/src/shared/.eslintrc.json b/src/shared/.eslintrc.json index 46f19570776a..cd108372cebd 100644 --- a/src/shared/.eslintrc.json +++ b/src/shared/.eslintrc.json @@ -29,7 +29,7 @@ "plugin:import/warnings" ], "parserOptions": { - "ecmaVersion": 6, + "ecmaVersion": 9, "sourceType": "module" }, "settings": { diff --git a/src/shared/_build.js b/src/shared/_build.js index 3cc523e7cd1e..72bd5ab2a880 100644 --- a/src/shared/_build.js +++ b/src/shared/_build.js @@ -9,18 +9,13 @@ fs.readdirSync(__dirname).forEach(file => { const source = fs.readFileSync(path.join(__dirname, file), 'utf-8'); const ast = acorn.parse(source, { - ecmaVersion: 6, + ecmaVersion: 9, sourceType: 'module' }); ast.body.forEach(node => { if (node.type !== 'ExportNamedDeclaration') return; - // check no ES6+ slipped in - acorn.parse(source.slice(node.declaration.start, node.end), { - ecmaVersion: 5 - }); - const declaration = node.declaration; if (!declaration) return; diff --git a/test/runtime/index.js b/test/runtime/index.js index a184bb46d0d8..b491dafa2071 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -74,38 +74,6 @@ describe("runtime", () => { compileOptions.immutable = config.immutable; compileOptions.parser = v2 ? 'v2' : 'v1'; - // check that no ES2015+ syntax slipped in - if (!config.allowES2015) { - try { - const source = fs.readFileSync( - `test/runtime/samples/${dir}/main${v2 ? '-v2' : ''}.html`, - "utf-8" - ); - const { code } = compile(source, compileOptions); - const startIndex = code.indexOf("function create_main_fragment"); // may change! - if (startIndex === -1) throw new Error("missing create_main_fragment"); - const endIndex = code.lastIndexOf("export default"); - const es5 = - code.slice(0, startIndex).split('\n').map(x => spaces(x.length)).join('\n') + - code.slice(startIndex, endIndex); - - acorn.parse(es5, { ecmaVersion: 5 }); - - if (/Object\.assign/.test(es5)) { - throw new Error( - "cannot use Object.assign in generated code, as it is not supported everywhere" - ); - } - } catch (err) { - failed.add(dir); - if (err.frame) { - console.error(chalk.red(err.frame)); // eslint-disable-line no-console - } - showOutput(cwd, { shared, format: 'cjs', store: !!compileOptions.store, v2 }, compile); // eslint-disable-line no-console - throw err; - } - } - Object.keys(require.cache) .filter(x => x.endsWith(".html")) .forEach(file => { diff --git a/test/runtime/samples/binding-indirect/_config.js b/test/runtime/samples/binding-indirect/_config.js index 9fdfa23a25c7..343cd0d0d3d5 100644 --- a/test/runtime/samples/binding-indirect/_config.js +++ b/test/runtime/samples/binding-indirect/_config.js @@ -7,7 +7,6 @@ const tasks = [ export default { 'skip-ssr': true, - allowES2015: true, data: { tasks, diff --git a/test/runtime/samples/function-in-expression/_config.js b/test/runtime/samples/function-in-expression/_config.js index 14cfb8f89f55..9b79770eb93f 100644 --- a/test/runtime/samples/function-in-expression/_config.js +++ b/test/runtime/samples/function-in-expression/_config.js @@ -1,6 +1,4 @@ export default { - allowES2015: true, - data: { numbers: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] }, diff --git a/test/store/index.js b/test/store/index.js index fd84322d3528..0e989c03f54f 100644 --- a/test/store/index.js +++ b/test/store/index.js @@ -5,23 +5,6 @@ import { parse } from 'acorn'; import { Store } from '../../store.js'; describe('store', () => { - it('is written in ES5', () => { - const source = fs.readFileSync('store.js', 'utf-8'); - - const ast = parse(source, { - sourceType: 'module' - }); - - const magicString = new MagicString(source); - ast.body.forEach(node => { - if (/^(Im|Ex)port/.test(node.type)) magicString.remove(node.start, node.end); - }); - - parse(magicString.toString(), { - ecmaVersion: 5 - }); - }); - describe('get', () => { it('gets a specific key', () => { const store = new Store({ From 7b40fed197b001fa9786d3263afe6bd3413b71d2 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 18:07:53 -0400 Subject: [PATCH 03/40] remove unused store methods --- store.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/store.js b/store.js index 7aef7b2046b4..42f17c9bb87b 100644 --- a/store.js +++ b/store.js @@ -4,13 +4,11 @@ import { _differs, _differsImmutable, get, - observe, on, fire } from './shared.js'; function Store(state, options) { - this._observers = { pre: blankObject(), post: blankObject() }; this._handlers = {}; this._dependents = []; @@ -110,20 +108,8 @@ assign(Store.prototype, { get: get, - // TODO remove this method - observe: observe, - on: on, - onchange: function(callback) { - // TODO remove this method - console.warn("store.onchange is deprecated in favour of store.on('state', event => {...})"); - - return this.on('state', function(event) { - callback(event.current, event.changed); - }); - }, - set: function(newState) { var oldState = this._state, changed = this._changed = {}, From 9070969418509f8722bc401ded0a18383df2353c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 18:08:01 -0400 Subject: [PATCH 04/40] remove references to obsolete methods --- src/generators/dom/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index eb7533187c8e..e3bb7e669749 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -143,8 +143,8 @@ export default function dom( ? `@proto` : deindent` { - ${['destroy', 'get', 'fire', 'observe', 'on', 'set', 'teardown', '_set', '_mount', '_unmount', '_differs'] - .map(n => `${n}: @${n === 'teardown' ? 'destroy' : n}`) + ${['destroy', 'get', 'fire', 'on', 'set', '_set', '_mount', '_unmount', '_differs'] + .map(n => `${n}: @${n}`) .join(',\n')} }`; From 9bc8b74107f7a8d994adbfe00c6b576f204c185c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 18:21:54 -0400 Subject: [PATCH 05/40] update store tests --- test/store/index.js | 108 +++++++++++++------------------------------- 1 file changed, 32 insertions(+), 76 deletions(-) diff --git a/test/store/index.js b/test/store/index.js index 0e989c03f54f..8bddb046f148 100644 --- a/test/store/index.js +++ b/test/store/index.js @@ -6,14 +6,6 @@ import { Store } from '../../store.js'; describe('store', () => { describe('get', () => { - it('gets a specific key', () => { - const store = new Store({ - foo: 'bar' - }); - - assert.equal(store.get('foo'), 'bar'); - }); - it('gets the entire state object', () => { const store = new Store({ foo: 'bar' @@ -31,12 +23,12 @@ describe('store', () => { foo: 'bar' }); - assert.equal(store.get('foo'), 'bar'); + assert.equal(store.get().foo, 'bar'); }); }); - describe('observe', () => { - it('observes state', () => { + describe('on', () => { + it('listens to an event', () => { let newFoo; let oldFoo; @@ -44,65 +36,39 @@ describe('store', () => { foo: 'bar' }); - store.observe('foo', (n, o) => { - newFoo = n; - oldFoo = o; + store.on('state', ({ changed, current, previous }) => { + newFoo = current.foo; + oldFoo = previous.foo; }); - assert.equal(newFoo, 'bar'); - assert.equal(oldFoo, undefined); - - store.set({ - foo: 'baz' - }); + store.set({ foo: 'baz' }); assert.equal(newFoo, 'baz'); assert.equal(oldFoo, 'bar'); }); }); - describe('onchange', () => { - it('fires a callback when state changes', () => { - const store = new Store(); - - let count = 0; - let args; - - store.onchange((state, changed) => { - count += 1; - args = { state, changed }; - }); - - store.set({ foo: 'bar' }); + describe('fire', () => { + let answer; - assert.equal(count, 1); - assert.deepEqual(args, { - state: { foo: 'bar' }, - changed: { foo: true } - }); + const store = new Store(); - // this should be a noop - store.set({ foo: 'bar' }); - assert.equal(count, 1); + store.on('custom', event => { + answer = event.answer; + }); - // this shouldn't - store.set({ foo: 'baz' }); + store.fire('custom', { answer: 42 }); - assert.equal(count, 2); - assert.deepEqual(args, { - state: { foo: 'baz' }, - changed: { foo: true } - }); - }); + assert.equal(answer, 42); }); it('allows user to cancel state change callback', () => { const store = new Store(); - const handler = store.onchange(() => {}); + const handler = store.on('state', () => {}); assert.doesNotThrow(() => { handler.cancel(); - }, TypeError, 'this._changeHandlers is undefined'); + }, TypeError, 'this._handlers is undefined'); }); describe('computed', () => { @@ -112,16 +78,16 @@ describe('store', () => { }); store.compute('bar', ['foo'], foo => foo * 2); - assert.equal(store.get('bar'), 2); + assert.equal(store.get().bar, 2); const values = []; - store.observe('bar', bar => { - values.push(bar); + store.on('state', ({ current }) => { + values.push(current.bar); }); store.set({ foo: 2 }); - assert.deepEqual(values, [2, 4]); + assert.deepEqual(values, [4]); }); it('computes a property based on another computed property', () => { @@ -131,16 +97,16 @@ describe('store', () => { store.compute('bar', ['foo'], foo => foo * 2); store.compute('baz', ['bar'], bar => bar * 2); - assert.equal(store.get('baz'), 4); + assert.equal(store.get().baz, 4); const values = []; - store.observe('baz', baz => { - values.push(baz); + store.on('state', ({ current }) => { + values.push(current.baz); }); store.set({ foo: 2 }); - assert.deepEqual(values, [4, 8]); + assert.deepEqual(values, [8]); }); it('prevents computed properties from being set', () => { @@ -192,29 +158,19 @@ describe('store', () => { foo: value1 }, { immutable: true }); - store.observe('foo', (n, o) => { + store.on('state', ({ current, previous }) => { callCount++; - newFoo = n; - oldFoo = o; + newFoo = current.foo; + oldFoo = previous.foo; }); - assert.equal(callCount, 1); - assert.equal(newFoo, value1); - assert.equal(oldFoo, undefined); + store.set({ foo: value1 }); - store.set({ - foo: value1 - }); + assert.equal(callCount, 0); - assert.equal(callCount, 1); - assert.equal(newFoo, value1); - assert.equal(oldFoo, undefined); + store.set({ foo: value2 }); - store.set({ - foo: value2 - }); - - assert.equal(callCount, 2); + assert.equal(callCount, 1); assert.equal(newFoo, value2); assert.equal(oldFoo, value1); }); From daa2635cd36b1c794a3fcb204be4100265dbc57d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 18:27:38 -0400 Subject: [PATCH 06/40] update snapshot tests --- test/js/samples/action/expected-bundle.js | 36 ++++--------- .../_actual-bundle-v2.js | 36 ++++--------- .../expected-bundle-v2.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../component-static/expected-bundle.js | 36 ++++--------- .../computed-collapsed-if/expected-bundle.js | 36 ++++--------- .../css-media-query/expected-bundle.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../deconflict-builtins/_actual-bundle-v2.js | 36 ++++--------- .../deconflict-builtins/expected-bundle-v2.js | 36 ++++--------- .../deconflict-builtins/expected-bundle.js | 36 ++++--------- .../deconflict-globals/expected-bundle.js | 36 ++++--------- .../_actual-bundle-v2.js | 51 +++---------------- .../expected-bundle-v2.js | 51 +++---------------- .../expected-bundle.js | 51 +++---------------- .../do-use-dataset/_actual-bundle-v2.js | 36 ++++--------- .../do-use-dataset/expected-bundle-v2.js | 36 ++++--------- .../samples/do-use-dataset/expected-bundle.js | 36 ++++--------- .../_actual-bundle-v2.js | 36 ++++--------- .../expected-bundle-v2.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../_actual-bundle-v2.js | 36 ++++--------- .../expected-bundle-v2.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../_actual-bundle-v2.js | 36 ++++--------- .../expected-bundle-v2.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../event-handlers-custom/expected-bundle.js | 36 ++++--------- .../head-no-whitespace/_actual-bundle-v2.js | 36 ++++--------- .../head-no-whitespace/expected-bundle-v2.js | 36 ++++--------- .../head-no-whitespace/expected-bundle.js | 36 ++++--------- .../if-block-no-update/_actual-bundle-v2.js | 36 ++++--------- .../if-block-no-update/expected-bundle-v2.js | 36 ++++--------- .../if-block-no-update/expected-bundle.js | 36 ++++--------- .../if-block-simple/_actual-bundle-v2.js | 36 ++++--------- .../if-block-simple/expected-bundle-v2.js | 36 ++++--------- .../if-block-simple/expected-bundle.js | 36 ++++--------- .../_actual-bundle-v2.js | 36 ++++--------- .../expected-bundle-v2.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../_actual-bundle-v2.js | 36 ++++--------- .../expected-bundle-v2.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../_actual-bundle-v2.js | 36 ++++--------- .../expected-bundle-v2.js | 36 ++++--------- .../inline-style-optimized/expected-bundle.js | 36 ++++--------- .../_actual-bundle-v2.js | 36 ++++--------- .../expected-bundle-v2.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../samples/legacy-default/expected-bundle.js | 36 ++++--------- .../legacy-input-type/expected-bundle.js | 36 ++++--------- .../legacy-quote-class/expected-bundle.js | 36 ++++--------- .../samples/media-bindings/expected-bundle.js | 36 ++++--------- .../non-imported-component/expected-bundle.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../samples/setup-method/expected-bundle.js | 36 ++++--------- test/js/samples/svg-title/expected-bundle.js | 36 ++++--------- test/js/samples/title/_actual-bundle-v2.js | 36 ++++--------- test/js/samples/title/expected-bundle-v2.js | 36 ++++--------- test/js/samples/title/expected-bundle.js | 36 ++++--------- .../_actual-bundle-v2.js | 36 ++++--------- .../expected-bundle-v2.js | 36 ++++--------- .../expected-bundle.js | 36 ++++--------- .../_actual-bundle-v2.js | 36 ++++--------- .../expected-bundle-v2.js | 36 ++++--------- .../window-binding-scroll/expected-bundle.js | 36 ++++--------- .../_config.js | 6 +-- .../main.html | 0 71 files changed, 753 insertions(+), 1782 deletions(-) rename test/runtime/samples/{store-observe-dollar => store-onstate-dollar}/_config.js (69%) rename test/runtime/samples/{store-observe-dollar => store-onstate-dollar}/main.html (100%) diff --git a/test/js/samples/action/expected-bundle.js b/test/js/samples/action/expected-bundle.js index e316279a1c8a..c58cbdcea3a3 100644 --- a/test/js/samples/action/expected-bundle.js +++ b/test/js/samples/action/expected-bundle.js @@ -51,8 +51,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -64,18 +64,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -134,18 +122,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/collapses-text-around-comments/_actual-bundle-v2.js b/test/js/samples/collapses-text-around-comments/_actual-bundle-v2.js index af5c88e15220..1c6d4db78ab3 100644 --- a/test/js/samples/collapses-text-around-comments/_actual-bundle-v2.js +++ b/test/js/samples/collapses-text-around-comments/_actual-bundle-v2.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle-v2.js b/test/js/samples/collapses-text-around-comments/expected-bundle-v2.js index af5c88e15220..1c6d4db78ab3 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle-v2.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle-v2.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle.js b/test/js/samples/collapses-text-around-comments/expected-bundle.js index af5c88e15220..1c6d4db78ab3 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js index 27aa216840e0..959b6fea5645 100644 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -43,8 +43,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -56,18 +56,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -126,18 +114,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js index 27aa216840e0..959b6fea5645 100644 --- a/test/js/samples/component-static-immutable2/expected-bundle.js +++ b/test/js/samples/component-static-immutable2/expected-bundle.js @@ -43,8 +43,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -56,18 +56,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -126,18 +114,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index 91fb33207b16..b7f9dcbbb996 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,18 +52,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -122,18 +110,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 95e448f87489..5ed48c2966bc 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,18 +52,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -122,18 +110,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index 79e3e3e456b6..f4076b12139a 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js index e320ba4218b5..edf44bfd7a76 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -51,8 +51,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -64,18 +64,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -134,18 +122,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/deconflict-builtins/_actual-bundle-v2.js b/test/js/samples/deconflict-builtins/_actual-bundle-v2.js index a8dcb7e5f464..e895d021e6f8 100644 --- a/test/js/samples/deconflict-builtins/_actual-bundle-v2.js +++ b/test/js/samples/deconflict-builtins/_actual-bundle-v2.js @@ -69,8 +69,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -82,18 +82,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -152,18 +140,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/deconflict-builtins/expected-bundle-v2.js b/test/js/samples/deconflict-builtins/expected-bundle-v2.js index a8dcb7e5f464..e895d021e6f8 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle-v2.js +++ b/test/js/samples/deconflict-builtins/expected-bundle-v2.js @@ -69,8 +69,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -82,18 +82,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -152,18 +140,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js index ee08884e3d1b..1e9eb4b70913 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ b/test/js/samples/deconflict-builtins/expected-bundle.js @@ -69,8 +69,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -82,18 +82,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -152,18 +140,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index 17898cf41485..8d23561dec85 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,18 +52,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -122,18 +110,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js b/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js index 69a58fa93330..c048d39b9949 100644 --- a/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js +++ b/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js @@ -66,13 +66,8 @@ function fire(eventName, data) { } } -function getDev(key) { - if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); - return get.call(this, key); -} - -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -84,34 +79,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function observeDev(key, callback, options) { - console.warn("this.observe(key, (newValue, oldValue) => {...}) is deprecated. Use\n\n // runs before DOM updates\n this.on('state', ({ changed, current, previous }) => {...});\n\n // runs after DOM updates\n this.on('update', ...);\n\n...or add the observe method from the svelte-extras package"); - - var c = (key = '' + key).search(/[.[]/); - if (c > -1) { - var message = - 'The first argument to component.observe(...) must be the name of a top-level property'; - if (c > 0) - message += ", i.e. '" + key.slice(0, c) + "' rather than '" + key + "'"; - - throw new Error(message); - } - - return observe.call(this, key, callback, options); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -193,17 +160,15 @@ function _unmount() { var protoDev = { destroy: destroyDev, - get: getDev, - fire: fire, - observe: observeDev, + get, + fire, on: onDev, set: setDev, - teardown: destroyDev, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js index 69a58fa93330..c048d39b9949 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js @@ -66,13 +66,8 @@ function fire(eventName, data) { } } -function getDev(key) { - if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); - return get.call(this, key); -} - -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -84,34 +79,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function observeDev(key, callback, options) { - console.warn("this.observe(key, (newValue, oldValue) => {...}) is deprecated. Use\n\n // runs before DOM updates\n this.on('state', ({ changed, current, previous }) => {...});\n\n // runs after DOM updates\n this.on('update', ...);\n\n...or add the observe method from the svelte-extras package"); - - var c = (key = '' + key).search(/[.[]/); - if (c > -1) { - var message = - 'The first argument to component.observe(...) must be the name of a top-level property'; - if (c > 0) - message += ", i.e. '" + key.slice(0, c) + "' rather than '" + key + "'"; - - throw new Error(message); - } - - return observe.call(this, key, callback, options); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -193,17 +160,15 @@ function _unmount() { var protoDev = { destroy: destroyDev, - get: getDev, - fire: fire, - observe: observeDev, + get, + fire, on: onDev, set: setDev, - teardown: destroyDev, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js index caaf43221f89..ef60f3ec411c 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js @@ -66,13 +66,8 @@ function fire(eventName, data) { } } -function getDev(key) { - if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); - return get.call(this, key); -} - -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -84,34 +79,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function observeDev(key, callback, options) { - console.warn("this.observe(key, (newValue, oldValue) => {...}) is deprecated. Use\n\n // runs before DOM updates\n this.on('state', ({ changed, current, previous }) => {...});\n\n // runs after DOM updates\n this.on('update', ...);\n\n...or add the observe method from the svelte-extras package"); - - var c = (key = '' + key).search(/[.[]/); - if (c > -1) { - var message = - 'The first argument to component.observe(...) must be the name of a top-level property'; - if (c > 0) - message += ", i.e. '" + key.slice(0, c) + "' rather than '" + key + "'"; - - throw new Error(message); - } - - return observe.call(this, key, callback, options); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -193,17 +160,15 @@ function _unmount() { var protoDev = { destroy: destroyDev, - get: getDev, - fire: fire, - observe: observeDev, + get, + fire, on: onDev, set: setDev, - teardown: destroyDev, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/do-use-dataset/_actual-bundle-v2.js b/test/js/samples/do-use-dataset/_actual-bundle-v2.js index 37bc15d30240..d16e73a4877f 100644 --- a/test/js/samples/do-use-dataset/_actual-bundle-v2.js +++ b/test/js/samples/do-use-dataset/_actual-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/do-use-dataset/expected-bundle-v2.js b/test/js/samples/do-use-dataset/expected-bundle-v2.js index 37bc15d30240..d16e73a4877f 100644 --- a/test/js/samples/do-use-dataset/expected-bundle-v2.js +++ b/test/js/samples/do-use-dataset/expected-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js index 37bc15d30240..d16e73a4877f 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js b/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js index be43fd0e9b4d..925c6e692b46 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js +++ b/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js index be43fd0e9b4d..925c6e692b46 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js index be43fd0e9b4d..925c6e692b46 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js b/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js index 1092b9ab86de..3ad8d8e9885e 100644 --- a/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js +++ b/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js b/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js index 1092b9ab86de..3ad8d8e9885e 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js index 1092b9ab86de..3ad8d8e9885e 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/each-block-changed-check/_actual-bundle-v2.js b/test/js/samples/each-block-changed-check/_actual-bundle-v2.js index f7d0080cbdac..5a2805c66951 100644 --- a/test/js/samples/each-block-changed-check/_actual-bundle-v2.js +++ b/test/js/samples/each-block-changed-check/_actual-bundle-v2.js @@ -71,8 +71,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -84,18 +84,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -154,18 +142,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/each-block-changed-check/expected-bundle-v2.js b/test/js/samples/each-block-changed-check/expected-bundle-v2.js index f7d0080cbdac..5a2805c66951 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle-v2.js +++ b/test/js/samples/each-block-changed-check/expected-bundle-v2.js @@ -71,8 +71,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -84,18 +84,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -154,18 +142,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js index a3023dc6b1b6..80b5d1220ce5 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -71,8 +71,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -84,18 +84,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -154,18 +142,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 861a3afc78bd..977e92dec656 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -51,8 +51,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -64,18 +64,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -134,18 +122,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/head-no-whitespace/_actual-bundle-v2.js b/test/js/samples/head-no-whitespace/_actual-bundle-v2.js index e17d8ede6182..cb51aacad9d8 100644 --- a/test/js/samples/head-no-whitespace/_actual-bundle-v2.js +++ b/test/js/samples/head-no-whitespace/_actual-bundle-v2.js @@ -51,8 +51,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -64,18 +64,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -134,18 +122,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/head-no-whitespace/expected-bundle-v2.js b/test/js/samples/head-no-whitespace/expected-bundle-v2.js index e17d8ede6182..cb51aacad9d8 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle-v2.js +++ b/test/js/samples/head-no-whitespace/expected-bundle-v2.js @@ -51,8 +51,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -64,18 +64,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -134,18 +122,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js index e17d8ede6182..cb51aacad9d8 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -51,8 +51,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -64,18 +64,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -134,18 +122,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/if-block-no-update/_actual-bundle-v2.js b/test/js/samples/if-block-no-update/_actual-bundle-v2.js index 5569d332f8a6..12168d6294a4 100644 --- a/test/js/samples/if-block-no-update/_actual-bundle-v2.js +++ b/test/js/samples/if-block-no-update/_actual-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/if-block-no-update/expected-bundle-v2.js b/test/js/samples/if-block-no-update/expected-bundle-v2.js index 5569d332f8a6..12168d6294a4 100644 --- a/test/js/samples/if-block-no-update/expected-bundle-v2.js +++ b/test/js/samples/if-block-no-update/expected-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js index c48994fc3bac..9f75086f359d 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/if-block-simple/_actual-bundle-v2.js b/test/js/samples/if-block-simple/_actual-bundle-v2.js index 336cd0bc5d15..76e6919ebd4f 100644 --- a/test/js/samples/if-block-simple/_actual-bundle-v2.js +++ b/test/js/samples/if-block-simple/_actual-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/if-block-simple/expected-bundle-v2.js b/test/js/samples/if-block-simple/expected-bundle-v2.js index 336cd0bc5d15..76e6919ebd4f 100644 --- a/test/js/samples/if-block-simple/expected-bundle-v2.js +++ b/test/js/samples/if-block-simple/expected-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 47065fea5866..676d6d0d4e13 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js index 035b3d9414a6..f15569295ab2 100644 --- a/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js +++ b/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js b/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js index 035b3d9414a6..f15569295ab2 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js index 035b3d9414a6..f15569295ab2 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js index b08091489f6e..77130c71b326 100644 --- a/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js +++ b/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js b/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js index b08091489f6e..77130c71b326 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized-url/expected-bundle.js b/test/js/samples/inline-style-optimized-url/expected-bundle.js index b08091489f6e..77130c71b326 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized/_actual-bundle-v2.js index fcd458c35683..1f444ef70485 100644 --- a/test/js/samples/inline-style-optimized/_actual-bundle-v2.js +++ b/test/js/samples/inline-style-optimized/_actual-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized/expected-bundle-v2.js b/test/js/samples/inline-style-optimized/expected-bundle-v2.js index fcd458c35683..1f444ef70485 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle-v2.js +++ b/test/js/samples/inline-style-optimized/expected-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js index fcd458c35683..1f444ef70485 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js b/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js index f7034d900720..8ce9a079cdd5 100644 --- a/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js +++ b/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js b/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js index f7034d900720..8ce9a079cdd5 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js index f7034d900720..8ce9a079cdd5 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,18 +68,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -138,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/input-without-blowback-guard/expected-bundle.js b/test/js/samples/input-without-blowback-guard/expected-bundle.js index 4b8909150b99..f81413a0fcb5 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -63,8 +63,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -76,18 +76,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -146,18 +134,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/legacy-default/expected-bundle.js b/test/js/samples/legacy-default/expected-bundle.js index b400d303d7c7..9c444e4097fc 100644 --- a/test/js/samples/legacy-default/expected-bundle.js +++ b/test/js/samples/legacy-default/expected-bundle.js @@ -73,8 +73,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -86,18 +86,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -156,18 +144,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index ff4b0b5e2b23..67be76877345 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -57,8 +57,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -70,18 +70,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -140,18 +128,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/legacy-quote-class/expected-bundle.js b/test/js/samples/legacy-quote-class/expected-bundle.js index fc088bf34a55..4c44d15ccb9e 100644 --- a/test/js/samples/legacy-quote-class/expected-bundle.js +++ b/test/js/samples/legacy-quote-class/expected-bundle.js @@ -74,8 +74,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -87,18 +87,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -157,18 +145,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index 7d8c7624eab7..2926e5a5a072 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -67,8 +67,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -80,18 +80,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -150,18 +138,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 06d1b0d4ea60..d6991d3b7265 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -53,8 +53,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -66,18 +66,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -136,18 +124,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index 4b1a9fc4812e..de7133b48c28 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,18 +52,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -122,18 +110,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 39f5d28c8055..8267343f1291 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,18 +52,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -122,18 +110,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index 804ce01d7c45..6d67ee7a1de6 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/title/_actual-bundle-v2.js b/test/js/samples/title/_actual-bundle-v2.js index df4a5e21253d..cc4b9229c83c 100644 --- a/test/js/samples/title/_actual-bundle-v2.js +++ b/test/js/samples/title/_actual-bundle-v2.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,18 +52,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -122,18 +110,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/title/expected-bundle-v2.js b/test/js/samples/title/expected-bundle-v2.js index df4a5e21253d..cc4b9229c83c 100644 --- a/test/js/samples/title/expected-bundle-v2.js +++ b/test/js/samples/title/expected-bundle-v2.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,18 +52,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -122,18 +110,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index df4a5e21253d..cc4b9229c83c 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,18 +52,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -122,18 +110,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js b/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js index 5fe8f188a29a..26852a55406d 100644 --- a/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js +++ b/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js @@ -63,8 +63,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -76,18 +76,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -146,18 +134,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js b/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js index 5fe8f188a29a..26852a55406d 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js @@ -63,8 +63,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -76,18 +76,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -146,18 +134,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle.js b/test/js/samples/use-elements-as-anchors/expected-bundle.js index 9ac8ca4ebeec..451a9fb9b6ff 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -63,8 +63,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -76,18 +76,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -146,18 +134,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/window-binding-scroll/_actual-bundle-v2.js b/test/js/samples/window-binding-scroll/_actual-bundle-v2.js index a6afbf9b14aa..ef796382c4a0 100644 --- a/test/js/samples/window-binding-scroll/_actual-bundle-v2.js +++ b/test/js/samples/window-binding-scroll/_actual-bundle-v2.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/window-binding-scroll/expected-bundle-v2.js b/test/js/samples/window-binding-scroll/expected-bundle-v2.js index a6afbf9b14aa..ef796382c4a0 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle-v2.js +++ b/test/js/samples/window-binding-scroll/expected-bundle-v2.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index a6afbf9b14aa..ef796382c4a0 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,18 +72,6 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { if (eventName === 'teardown') return this.on('destroy', handler); @@ -142,18 +130,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/runtime/samples/store-observe-dollar/_config.js b/test/runtime/samples/store-onstate-dollar/_config.js similarity index 69% rename from test/runtime/samples/store-observe-dollar/_config.js rename to test/runtime/samples/store-onstate-dollar/_config.js index 1861b937d95e..0b638bcd0170 100644 --- a/test/runtime/samples/store-observe-dollar/_config.js +++ b/test/runtime/samples/store-onstate-dollar/_config.js @@ -14,12 +14,12 @@ export default { test(assert, component) { const names = []; - component.observe('$name', name => { - names.push(name); + component.on('state', ({ current }) => { + names.push(current.$name); }); store.set({ name: 'everybody' }); - assert.deepEqual(names, ['world', 'everybody']); + assert.deepEqual(names, ['everybody']); } }; \ No newline at end of file diff --git a/test/runtime/samples/store-observe-dollar/main.html b/test/runtime/samples/store-onstate-dollar/main.html similarity index 100% rename from test/runtime/samples/store-observe-dollar/main.html rename to test/runtime/samples/store-onstate-dollar/main.html From 2f86bd339dd0b28af201d0b9ca48fc87e3b18af9 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 19:08:49 -0400 Subject: [PATCH 07/40] update tests to account for removal of observe --- src/generators/nodes/Element.ts | 10 +------ src/generators/nodes/Window.ts | 10 +------ src/shared/index.js | 15 +---------- test/custom-elements/samples/html/test.js | 2 +- .../samples/binding-input/_config.js | 2 +- .../samples/event-handler/_config.js | 2 +- .../attribute-dynamic-shorthand/_config.js | 2 -- .../samples/await-then-catch-event/_config.js | 4 +-- .../_config.js | 16 ++++++------ .../binding-indirect-computed/_config.js | 2 +- .../samples/binding-indirect/_config.js | 6 ++--- .../_config.js | 4 +-- .../_config.js | 4 +-- .../samples/binding-input-number/_config.js | 4 +-- .../binding-input-range-change/_config.js | 2 +- .../samples/binding-input-range/_config.js | 2 +- .../binding-input-text-contextual/_config.js | 2 +- .../_config.js | 2 +- .../_config.js | 2 +- .../binding-input-text-deep/_config.js | 2 +- .../binding-input-with-event/_config.js | 2 +- .../_config.js | 4 +-- .../binding-select-in-each-block/_config.js | 2 +- .../binding-select-in-yield/Modal.html | 2 +- .../binding-select-in-yield/_config.js | 2 +- .../binding-select-multiple/_config.js | 4 +-- .../binding-select-optgroup/_config.js | 4 +-- .../runtime/samples/binding-select/_config.js | 4 +-- .../samples/bindings-before-oncreate/One.html | 2 +- .../component-binding-blowback-b/Nested.html | 2 +- .../component-binding-blowback-c/Nested.html | 2 +- .../component-binding-blowback/_config.js | 10 +++---- .../component-binding-computed/_config.js | 4 +-- .../component-binding-deep-b/_config.js | 4 +-- .../component-binding-deep-b/main.html | 26 ++++++++++--------- .../samples/component-binding-deep/_config.js | 2 +- .../component-binding-each-nested/_config.js | 4 +-- .../samples/component-binding-each/_config.js | 2 +- .../component-binding-infinite-loop/C.html | 4 +-- .../_config.js | 4 +-- .../component-binding-nested/_config.js | 6 ++--- .../_config.js | 4 +-- .../_config.js | 4 +-- .../samples/component-binding/_config.js | 4 +-- .../_config.js | 2 -- .../samples/component-events/main.html | 2 +- .../samples/component-yield-if/_config.js | 2 +- .../samples/component-yield-parent/_config.js | 4 +-- .../runtime/samples/computed-empty/_config.js | 2 +- .../_config.js | 2 +- .../samples/computed-values/_config.js | 4 +-- test/runtime/samples/custom-method/_config.js | 4 +-- test/runtime/samples/custom-method/main.html | 2 +- .../samples/deconflict-builtins/_config.js | 2 +- .../samples/deconflict-non-helpers/_config.js | 2 +- .../_config.js | 7 ----- .../main.html | 9 ------- .../_config.js | 7 ----- .../main.html | 16 ------------ .../_config.js | 7 ----- .../main.html | 9 ------- .../dynamic-component-bindings/_config.js | 4 +-- .../dynamic-component-events/_config.js | 4 +-- .../each-block-array-literal/_config.js | 2 +- .../each-block-containing-if/_config.js | 2 +- .../event-handler-custom-context/main.html | 4 +-- .../_config.js | 4 +-- .../main.html | 2 +- .../event-handler-custom-each/_config.js | 4 +-- .../event-handler-custom-each/main.html | 2 +- .../main.html | 2 +- .../samples/event-handler-custom/main.html | 2 +- .../_config.js | 4 +-- .../event-handler-event-methods/_config.js | 4 +-- .../samples/event-handler-removal/_config.js | 4 +-- .../samples/flush-before-bindings/_config.js | 2 +- .../samples/flush-before-bindings/main.html | 14 ++++++---- test/runtime/samples/get-state/_config.js | 4 +-- .../_config.js | 2 +- .../samples/immutable-mutable/Nested.html | 18 ++++++------- .../samples/immutable-mutable/_config.js | 12 +++++---- .../samples/immutable-nested/_config.js | 12 +++++---- .../runtime/samples/immutable-root/_config.js | 12 +++++---- .../_config.js | 6 ++--- .../_config.js | 10 +++---- .../samples/observe-deferred/main.html | 10 +++---- .../samples/observe-prevents-loop/_config.js | 20 +++++++------- .../oncreate-sibling-order/Nested.html | 2 +- test/runtime/samples/onrender-chain/Item.html | 10 +++---- .../samples/select-bind-in-array/_config.js | 2 +- .../samples/select-change-handler/_config.js | 4 +-- test/runtime/samples/select-props/_config.js | 2 +- .../Widget.html | 17 ------------ .../samples/set-in-ondestroy/_config.js | 8 +++--- .../Widget.html | 13 ++++++++++ .../_config.js | 0 .../main.html | 8 +++--- .../_config.js | 0 .../main.html | 8 +++--- test/runtime/samples/store-binding/_config.js | 2 +- .../store-component-binding-deep/_config.js | 10 +++---- .../store-component-binding-each/_config.js | 2 +- .../store-component-binding/_config.js | 10 +++---- .../runtime/samples/store-computed/_config.js | 2 +- test/runtime/samples/store-event/_config.js | 2 +- .../samples/window-event-context/_config.js | 4 +-- 106 files changed, 238 insertions(+), 320 deletions(-) delete mode 100644 test/runtime/samples/dev-warning-bad-observe-arguments/_config.js delete mode 100644 test/runtime/samples/dev-warning-bad-observe-arguments/main.html delete mode 100644 test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/_config.js delete mode 100644 test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/main.html delete mode 100644 test/runtime/samples/dev-warning-destroy-not-teardown/_config.js delete mode 100644 test/runtime/samples/dev-warning-destroy-not-teardown/main.html delete mode 100644 test/runtime/samples/set-in-observe-dedupes-renders/Widget.html create mode 100644 test/runtime/samples/set-in-onstate-dedupes-renders/Widget.html rename test/runtime/samples/{set-in-observe-dedupes-renders => set-in-onstate-dedupes-renders}/_config.js (100%) rename test/runtime/samples/{set-in-observe-dedupes-renders => set-in-onstate-dedupes-renders}/main.html (69%) rename test/runtime/samples/{set-in-observe => set-in-onstate}/_config.js (100%) rename test/runtime/samples/{set-in-observe => set-in-onstate}/main.html (52%) diff --git a/src/generators/nodes/Element.ts b/src/generators/nodes/Element.ts index d9f4e8f97444..6bf67c1c95a5 100644 --- a/src/generators/nodes/Element.ts +++ b/src/generators/nodes/Element.ts @@ -580,16 +580,8 @@ export default class Element extends Node { }); `); - if (generator.options.dev) { - block.builders.hydrate.addBlock(deindent` - if (${handlerName}.teardown) { - console.warn("Return 'destroy()' from custom event handlers. Returning 'teardown()' has been deprecated and will be unsupported in Svelte 2"); - } - `); - } - block.builders.destroy.addLine(deindent` - ${handlerName}[${handlerName}.destroy ? 'destroy' : 'teardown'](); + ${handlerName}.destroy(); `); } else { const handler = deindent` diff --git a/src/generators/nodes/Window.ts b/src/generators/nodes/Window.ts index 40138913e67c..92e55025b317 100644 --- a/src/generators/nodes/Window.ts +++ b/src/generators/nodes/Window.ts @@ -86,16 +86,8 @@ export default class Window extends Node { }); `); - if (generator.options.dev) { - block.builders.hydrate.addBlock(deindent` - if (${handlerName}.teardown) { - console.warn("Return 'destroy()' from custom event handlers. Returning 'teardown()' has been deprecated and will be unsupported in Svelte 2"); - } - `); - } - block.builders.destroy.addLine(deindent` - ${handlerName}[${handlerName}.destroy ? 'destroy' : 'teardown'](); + ${handlerName}.destroy(); `); } else { block.builders.init.addBlock(deindent` diff --git a/src/shared/index.js b/src/shared/index.js index 32b59dfde3e2..0d7cb43bddbb 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -65,8 +65,6 @@ export function init(component, options) { } export function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -78,17 +76,6 @@ export function on(eventName, handler) { }; } -export function onDev(eventName, handler) { - if (eventName === 'teardown') { - console.warn( - "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2" - ); - return this.on('destroy', handler); - } - - return on.call(this, eventName, handler); -} - export function run(fn) { fn(); } @@ -176,7 +163,7 @@ export var protoDev = { destroy: destroyDev, get, fire, - on: onDev, + on, set: setDev, _recompute: noop, _set, diff --git a/test/custom-elements/samples/html/test.js b/test/custom-elements/samples/html/test.js index a9aa2c7129f0..9f0a925b43e6 100644 --- a/test/custom-elements/samples/html/test.js +++ b/test/custom-elements/samples/html/test.js @@ -5,7 +5,7 @@ export default function (target) { target.innerHTML = ''; const el = target.querySelector('custom-element'); - assert.equal(el.get('name'), 'world'); + assert.equal(el.get().name, 'world'); const h1 = el.shadowRoot.querySelector('h1'); assert.equal(h1.textContent, 'Hello world!'); diff --git a/test/hydration/samples/binding-input/_config.js b/test/hydration/samples/binding-input/_config.js index 86ba3fe9ecc6..7dc18c8a6a4e 100644 --- a/test/hydration/samples/binding-input/_config.js +++ b/test/hydration/samples/binding-input/_config.js @@ -20,7 +20,7 @@ export default { input.value = 'everybody'; input.dispatchEvent(new window.Event('input')); - assert.equal(component.get('name'), 'everybody'); + assert.equal(component.get().name, 'everybody'); assert.htmlEqual(target.innerHTML, `

Hello everybody!

diff --git a/test/hydration/samples/event-handler/_config.js b/test/hydration/samples/event-handler/_config.js index 4cd132f8014b..233bafe38a42 100644 --- a/test/hydration/samples/event-handler/_config.js +++ b/test/hydration/samples/event-handler/_config.js @@ -17,7 +17,7 @@ export default { button.dispatchEvent(new window.MouseEvent('click')); - assert.ok(component.get('clicked')); + assert.ok(component.get().clicked); assert.htmlEqual(target.innerHTML, `

clicked!

diff --git a/test/runtime/samples/attribute-dynamic-shorthand/_config.js b/test/runtime/samples/attribute-dynamic-shorthand/_config.js index 1ecd6c650a91..e8ed048835c9 100644 --- a/test/runtime/samples/attribute-dynamic-shorthand/_config.js +++ b/test/runtime/samples/attribute-dynamic-shorthand/_config.js @@ -4,7 +4,5 @@ export default { test ( assert, component, target ) { component.set({ id: 'bar' }); assert.equal( target.innerHTML, `
` ); - - component.teardown(); } }; diff --git a/test/runtime/samples/await-then-catch-event/_config.js b/test/runtime/samples/await-then-catch-event/_config.js index f88a58ff1284..ec047fce02c5 100644 --- a/test/runtime/samples/await-then-catch-event/_config.js +++ b/test/runtime/samples/await-then-catch-event/_config.js @@ -26,7 +26,7 @@ export default { const click = new window.MouseEvent('click'); button.dispatchEvent(click); - assert.equal(component.get('clicked'), 42); + assert.equal(component.get().clicked, 42); thePromise = Promise.resolve(43); component.set({ thePromise }); @@ -39,7 +39,7 @@ export default { const click = new window.MouseEvent('click'); button.dispatchEvent(click); - assert.equal(component.get('clicked'), 43); + assert.equal(component.get().clicked, 43); }); } }; \ No newline at end of file diff --git a/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js b/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js index abb0eeaacb44..62312d17a903 100644 --- a/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js +++ b/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js @@ -5,10 +5,10 @@ export default { skip: true, test ( assert, component, target, window ) { - assert.equal( component.get( 't' ), 0 ); - assert.equal( component.get( 'd' ), 0 ); - assert.equal( component.get( 'v' ), 0.5 ); - assert.equal( component.get( 'paused' ), true ); + assert.equal( component.get().t, 0 ); + assert.equal( component.get().d, 0 ); + assert.equal( component.get().v, 0.5 ); + assert.equal( component.get().paused, true ); const audio = target.querySelector( 'audio' ); const timeupdate = new window.Event( 'timeupdate' ); @@ -23,10 +23,10 @@ export default { audio.dispatchEvent( volumechange ); audio.play(); - assert.equal( component.get( 't' ), 10 ); - assert.equal( component.get( 'd' ), 0 ); // not 20, because read-only. Not sure how to test this! - assert.equal( component.get( 'v' ), 0.75 ); - assert.equal( component.get( 'paused' ), true ); // ditto... + assert.equal( component.get().t, 10 ); + assert.equal( component.get().d, 0 ); // not 20, because read-only. Not sure how to test this! + assert.equal( component.get().v, 0.75 ); + assert.equal( component.get().paused, true ); // ditto... component.destroy(); } }; diff --git a/test/runtime/samples/binding-indirect-computed/_config.js b/test/runtime/samples/binding-indirect-computed/_config.js index f7ac841f21c8..595c5f3a9596 100644 --- a/test/runtime/samples/binding-indirect-computed/_config.js +++ b/test/runtime/samples/binding-indirect-computed/_config.js @@ -18,7 +18,7 @@ export default { options[1].selected = true; select.dispatchEvent(change); - assert.equal(component.get('selected').letter, 'B'); + assert.equal(component.get().selected.letter, 'B'); assert.htmlEqual(target.innerHTML, ` @@ -63,13 +63,13 @@ export default { options[1].selected = true; select.dispatchEvent(change); - assert.equal(component.get('selected'), tasks[1]); + assert.equal(component.get().selected, tasks[1]); assert.ok(!input.checked); input.checked = true; input.dispatchEvent(change); - assert.ok(component.get('tasks')[1].done); + assert.ok(component.get().tasks[1].done); assert.htmlEqual(target.innerHTML, `

one

two

three

2 completed

` ); - const items = component.get( 'items' ); + const items = component.get().items; items[2].completed = true; component.set({ items }); diff --git a/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js b/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js index 3d905e5a9e22..b480fbac3ec8 100644 --- a/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js +++ b/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js @@ -22,8 +22,8 @@ export default { input.indeterminate = false; input.dispatchEvent(event); - assert.equal(component.get('indeterminate'), false); - assert.equal(component.get('checked'), true); + assert.equal(component.get().indeterminate, false); + assert.equal(component.get().checked, true); assert.htmlEqual(target.innerHTML, `

checked? true

diff --git a/test/runtime/samples/binding-input-number/_config.js b/test/runtime/samples/binding-input-number/_config.js index 8fd406a2c4d1..66e0df8a35ea 100644 --- a/test/runtime/samples/binding-input-number/_config.js +++ b/test/runtime/samples/binding-input-number/_config.js @@ -17,7 +17,7 @@ export default { input.value = '43'; input.dispatchEvent( event ); - assert.equal( component.get( 'count' ), 43 ); + assert.equal( component.get().count, 43 ); assert.htmlEqual( target.innerHTML, `

number 43

@@ -34,7 +34,7 @@ export default { input.value = ''; input.dispatchEvent( event ); - assert.equal( component.get( 'count' ), undefined ); + assert.equal( component.get().count, undefined ); assert.htmlEqual( target.innerHTML, `

undefined undefined

diff --git a/test/runtime/samples/binding-input-range-change/_config.js b/test/runtime/samples/binding-input-range-change/_config.js index dd4b5f08a1b9..b76a8cffb4a8 100644 --- a/test/runtime/samples/binding-input-range-change/_config.js +++ b/test/runtime/samples/binding-input-range-change/_config.js @@ -17,7 +17,7 @@ export default { input.value = '43'; input.dispatchEvent( event ); - assert.equal( component.get( 'count' ), 43 ); + assert.equal( component.get().count, 43 ); assert.htmlEqual( target.innerHTML, `

number 43

diff --git a/test/runtime/samples/binding-input-range/_config.js b/test/runtime/samples/binding-input-range/_config.js index c1ff309e2f85..15c602e7f4fe 100644 --- a/test/runtime/samples/binding-input-range/_config.js +++ b/test/runtime/samples/binding-input-range/_config.js @@ -17,7 +17,7 @@ export default { input.value = '43'; input.dispatchEvent( event ); - assert.equal( component.get( 'count' ), 43 ); + assert.equal( component.get().count, 43 ); assert.htmlEqual( target.innerHTML, `

number 43

diff --git a/test/runtime/samples/binding-input-text-contextual/_config.js b/test/runtime/samples/binding-input-text-contextual/_config.js index 332d2c6f393e..a8949510d706 100644 --- a/test/runtime/samples/binding-input-text-contextual/_config.js +++ b/test/runtime/samples/binding-input-text-contextual/_config.js @@ -9,7 +9,7 @@ export default { html: `

one

two

three

`, test ( assert, component, target, window ) { const inputs = [ ...target.querySelectorAll( 'input' ) ]; - const items = component.get( 'items' ); + const items = component.get().items; const event = new window.Event( 'input' ); assert.equal( inputs[0].value, 'one' ); diff --git a/test/runtime/samples/binding-input-text-deep-computed/_config.js b/test/runtime/samples/binding-input-text-deep-computed/_config.js index 597395ed5201..33cc605a615e 100644 --- a/test/runtime/samples/binding-input-text-deep-computed/_config.js +++ b/test/runtime/samples/binding-input-text-deep-computed/_config.js @@ -20,7 +20,7 @@ export default { assert.equal( target.innerHTML, `\n

hello bob

` ); - const user = component.get( 'user' ); + const user = component.get().user; user.name = 'carol'; component.set({ user }); diff --git a/test/runtime/samples/binding-input-text-deep-contextual/_config.js b/test/runtime/samples/binding-input-text-deep-contextual/_config.js index 587110786c89..8cf72df95649 100644 --- a/test/runtime/samples/binding-input-text-deep-contextual/_config.js +++ b/test/runtime/samples/binding-input-text-deep-contextual/_config.js @@ -19,7 +19,7 @@ export default { assert.equal( target.innerHTML, `

one

four

three

` ); - const items = component.get( 'items' ); + const items = component.get().items; items[2].description = 'five'; component.set({ items }); diff --git a/test/runtime/samples/binding-input-text-deep/_config.js b/test/runtime/samples/binding-input-text-deep/_config.js index 9ef090f8648b..f1abe383a6c8 100644 --- a/test/runtime/samples/binding-input-text-deep/_config.js +++ b/test/runtime/samples/binding-input-text-deep/_config.js @@ -19,7 +19,7 @@ export default { assert.equal( target.innerHTML, `\n

hello bob

` ); - const user = component.get( 'user' ); + const user = component.get().user; user.name = 'carol'; component.set({ user }); diff --git a/test/runtime/samples/binding-input-with-event/_config.js b/test/runtime/samples/binding-input-with-event/_config.js index c09f09439b3e..1b4736e0aa58 100644 --- a/test/runtime/samples/binding-input-with-event/_config.js +++ b/test/runtime/samples/binding-input-with-event/_config.js @@ -13,7 +13,7 @@ export default { input.dispatchEvent( event ); assert.equal( input.value, '43' ); - assert.equal( component.get( 'a' ), 43 ); + assert.equal( component.get().a, 43 ); component.destroy(); } diff --git a/test/runtime/samples/binding-select-implicit-option-value/_config.js b/test/runtime/samples/binding-select-implicit-option-value/_config.js index 40a73647973c..1ab8de20aa7f 100644 --- a/test/runtime/samples/binding-select-implicit-option-value/_config.js +++ b/test/runtime/samples/binding-select-implicit-option-value/_config.js @@ -19,14 +19,14 @@ export default { const options = [...target.querySelectorAll('option')]; assert.ok(options[1].selected); - assert.equal(component.get('foo'), 2); + assert.equal(component.get().foo, 2); const change = new window.Event('change'); options[2].selected = true; select.dispatchEvent(change); - assert.equal(component.get('foo'), 3); + assert.equal(component.get().foo, 3); assert.htmlEqual( target.innerHTML, ` @@ -38,7 +38,7 @@ export default { options[0].selected = true; select.dispatchEvent( change ); - assert.deepEqual( component.get( 'selected' ), [ 'one', 'three' ] ); + assert.deepEqual( component.get().selected, [ 'one', 'three' ] ); assert.htmlEqual( target.innerHTML, ` @@ -67,7 +67,7 @@ export default { textarea.value = 'two source changed'; textarea.dispatchEvent( event ); - assert.equal( component.get( 'compiled' ), 'ONE SOURCE CHANGED\nTWO SOURCE CHANGED' ); + assert.equal( component.get().compiled, 'ONE SOURCE CHANGED\nTWO SOURCE CHANGED' ); assert.htmlEqual( target.innerHTML, `

blah

diff --git a/test/runtime/samples/component-binding-each-nested/_config.js b/test/runtime/samples/component-binding-each-nested/_config.js index 536996e869a8..83bd81dbcb4d 100644 --- a/test/runtime/samples/component-binding-each-nested/_config.js +++ b/test/runtime/samples/component-binding-each-nested/_config.js @@ -11,12 +11,12 @@ export default { inputs[0].value = 'blah'; inputs[0].dispatchEvent( event ); - assert.deepEqual( component.get( 'a' ), [{ name: 'blah' }, { name: 'bar' }, { name: 'baz' }] ); + assert.deepEqual( component.get().a, [{ name: 'blah' }, { name: 'bar' }, { name: 'baz' }] ); assert.htmlEqual( target.innerHTML, `

blah, bar, baz

` ); - + component.destroy(); } }; diff --git a/test/runtime/samples/component-binding-each/_config.js b/test/runtime/samples/component-binding-each/_config.js index 632898eb5a93..4ab071a28676 100644 --- a/test/runtime/samples/component-binding-each/_config.js +++ b/test/runtime/samples/component-binding-each/_config.js @@ -11,7 +11,7 @@ export default { inputs[0].value = 'blah'; inputs[0].dispatchEvent( event ); - assert.deepEqual( component.get( 'a' ), [ 'blah', 'bar', 'baz' ] ); + assert.deepEqual( component.get().a, [ 'blah', 'bar', 'baz' ] ); assert.htmlEqual( target.innerHTML, `

blah, bar, baz

diff --git a/test/runtime/samples/component-binding-infinite-loop/C.html b/test/runtime/samples/component-binding-infinite-loop/C.html index 40dcf908446f..e3887ff78e40 100644 --- a/test/runtime/samples/component-binding-infinite-loop/C.html +++ b/test/runtime/samples/component-binding-infinite-loop/C.html @@ -12,10 +12,10 @@ }, methods: { toggle() { - const isCurrentlySelected = this.get('isCurrentlySelected') + const isCurrentlySelected = this.get().isCurrentlySelected this.set({ - currentIdentifier: isCurrentlySelected ? null : this.get('identifier') + currentIdentifier: isCurrentlySelected ? null : this.get().identifier }) } } diff --git a/test/runtime/samples/component-binding-infinite-loop/_config.js b/test/runtime/samples/component-binding-infinite-loop/_config.js index 6a379af0a434..b9f7650e436d 100644 --- a/test/runtime/samples/component-binding-infinite-loop/_config.js +++ b/test/runtime/samples/component-binding-infinite-loop/_config.js @@ -31,7 +31,7 @@ export default { spans[0].dispatchEvent( click ); - assert.equal( component.get( 'currentIdentifier' ), 1 ); + assert.equal( component.get().currentIdentifier, 1 ); assert.htmlEqual( target.innerHTML, `

1

2

@@ -60,7 +60,7 @@ export default { spans[0].dispatchEvent( click ); - assert.equal( component.get( 'currentIdentifier' ), null ); + assert.equal( component.get().currentIdentifier, null ); assert.htmlEqual( target.innerHTML, `

1

2

diff --git a/test/runtime/samples/component-binding-nested/_config.js b/test/runtime/samples/component-binding-nested/_config.js index fd1250e7a5fa..d0fb9dc196a5 100644 --- a/test/runtime/samples/component-binding-nested/_config.js +++ b/test/runtime/samples/component-binding-nested/_config.js @@ -21,7 +21,7 @@ export default { buttons[0].dispatchEvent( click ); - assert.equal( component.get( 'x' ), 'p' ); + assert.equal( component.get().x, 'p' ); assert.htmlEqual( target.innerHTML, `

x: p

@@ -34,7 +34,7 @@ export default { buttons[1].dispatchEvent( click ); - assert.equal( component.get( 'x' ), 'q' ); + assert.equal( component.get().x, 'q' ); assert.htmlEqual( target.innerHTML, `

x: q

@@ -47,7 +47,7 @@ export default { buttons[2].dispatchEvent( click ); - assert.equal( component.get( 'x' ), 'r' ); + assert.equal( component.get().x, 'r' ); assert.htmlEqual( target.innerHTML, `

x: r

diff --git a/test/runtime/samples/component-binding-parent-supercedes-child/_config.js b/test/runtime/samples/component-binding-parent-supercedes-child/_config.js index 6fa49fce9f7d..65999b85fdb5 100644 --- a/test/runtime/samples/component-binding-parent-supercedes-child/_config.js +++ b/test/runtime/samples/component-binding-parent-supercedes-child/_config.js @@ -10,7 +10,7 @@ export default { button.dispatchEvent( click ); - assert.equal( component.get( 'x' ), 11 ); + assert.equal( component.get().x, 11 ); assert.htmlEqual( target.innerHTML, `

count: 11

@@ -18,7 +18,7 @@ export default { button.dispatchEvent( click ); - assert.equal( component.get( 'x' ), 12 ); + assert.equal( component.get().x, 12 ); assert.htmlEqual( target.innerHTML, `

count: 12

diff --git a/test/runtime/samples/component-binding-self-destroying/_config.js b/test/runtime/samples/component-binding-self-destroying/_config.js index 27a7ab108e9f..a78b1c55eadd 100644 --- a/test/runtime/samples/component-binding-self-destroying/_config.js +++ b/test/runtime/samples/component-binding-self-destroying/_config.js @@ -12,14 +12,14 @@ export default { target.querySelector('button').dispatchEvent(click); - assert.equal(component.get('show'), false); + assert.equal(component.get().show, false); assert.htmlEqual(target.innerHTML, ` `); target.querySelector('button').dispatchEvent(click); - assert.equal(component.get('show'), true); + assert.equal(component.get().show, true); assert.htmlEqual(target.innerHTML, ` `); diff --git a/test/runtime/samples/component-binding/_config.js b/test/runtime/samples/component-binding/_config.js index f2ed4d67e25d..aa64ab81b838 100644 --- a/test/runtime/samples/component-binding/_config.js +++ b/test/runtime/samples/component-binding/_config.js @@ -12,7 +12,7 @@ export default { button.dispatchEvent( click ); - assert.equal( component.get( 'x' ), 1 ); + assert.equal( component.get().x, 1 ); assert.htmlEqual( target.innerHTML, `

count: 1

@@ -20,7 +20,7 @@ export default { button.dispatchEvent( click ); - assert.equal( component.get( 'x' ), 2 ); + assert.equal( component.get().x, 2 ); assert.htmlEqual( target.innerHTML, `

count: 2

diff --git a/test/runtime/samples/component-data-dynamic-shorthand/_config.js b/test/runtime/samples/component-data-dynamic-shorthand/_config.js index c0a53c333c33..0e96bc9a8618 100644 --- a/test/runtime/samples/component-data-dynamic-shorthand/_config.js +++ b/test/runtime/samples/component-data-dynamic-shorthand/_config.js @@ -11,7 +11,5 @@ export default { }); assert.equal( target.innerHTML, `

foo: 99

` ); - - component.teardown(); } }; diff --git a/test/runtime/samples/component-events/main.html b/test/runtime/samples/component-events/main.html index 12c5f78472db..442ae0f989e1 100644 --- a/test/runtime/samples/component-events/main.html +++ b/test/runtime/samples/component-events/main.html @@ -1,6 +1,6 @@
{{#if visible}} - + {{/if}}
diff --git a/test/runtime/samples/component-yield-if/_config.js b/test/runtime/samples/component-yield-if/_config.js index a428e4522dab..8c09fedbabd1 100644 --- a/test/runtime/samples/component-yield-if/_config.js +++ b/test/runtime/samples/component-yield-if/_config.js @@ -4,7 +4,7 @@ export default { test ( assert, component, target ) { const widget = component.refs.widget; - assert.equal( widget.get( 'show' ), false ); + assert.equal( widget.get().show, false ); widget.set({show: true}); assert.htmlEqual( target.innerHTML, '

Hello

' ); diff --git a/test/runtime/samples/component-yield-parent/_config.js b/test/runtime/samples/component-yield-parent/_config.js index b80ee68bdb2b..39bc7cf79a74 100644 --- a/test/runtime/samples/component-yield-parent/_config.js +++ b/test/runtime/samples/component-yield-parent/_config.js @@ -4,10 +4,10 @@ export default { `, test ( assert, component, target ) { - assert.equal( component.get( 'data' ), 'Hello' ); + assert.equal( component.get().data, 'Hello' ); component.set({ data: 'World' }); - assert.equal( component.get( 'data' ), 'World' ); + assert.equal( component.get().data, 'World' ); assert.htmlEqual( target.innerHTML, `

World

` ); diff --git a/test/runtime/samples/computed-empty/_config.js b/test/runtime/samples/computed-empty/_config.js index 226be4cffee9..610cc1794524 100644 --- a/test/runtime/samples/computed-empty/_config.js +++ b/test/runtime/samples/computed-empty/_config.js @@ -1,7 +1,7 @@ export default { html: '
empty
', test ( assert, component, target ) { - assert.equal( component.get( 'created' ), true ); + assert.equal( component.get().created, true ); assert.equal( target.innerHTML, '
empty
' ); component.destroy(); } diff --git a/test/runtime/samples/computed-values-function-dependency/_config.js b/test/runtime/samples/computed-values-function-dependency/_config.js index 38b716b4d7a2..9320a0aad81d 100644 --- a/test/runtime/samples/computed-values-function-dependency/_config.js +++ b/test/runtime/samples/computed-values-function-dependency/_config.js @@ -3,7 +3,7 @@ export default { test ( assert, component, target ) { component.set({ y: 2 }); - assert.equal( component.get( 'x' ), 4 ); + assert.equal( component.get().x, 4 ); assert.equal( target.innerHTML, '

4

' ); component.destroy(); } diff --git a/test/runtime/samples/computed-values/_config.js b/test/runtime/samples/computed-values/_config.js index 8425cba4ff91..8d52627c40c4 100644 --- a/test/runtime/samples/computed-values/_config.js +++ b/test/runtime/samples/computed-values/_config.js @@ -2,8 +2,8 @@ export default { html: '

1 + 2 = 3

\n

3 * 3 = 9

', test ( assert, component, target ) { component.set({ a: 3 }); - assert.equal( component.get( 'c' ), 5 ); - assert.equal( component.get( 'cSquared' ), 25 ); + assert.equal( component.get().c, 5 ); + assert.equal( component.get().cSquared, 25 ); assert.equal( target.innerHTML, '

3 + 2 = 5

\n

5 * 5 = 25

' ); component.destroy(); } diff --git a/test/runtime/samples/custom-method/_config.js b/test/runtime/samples/custom-method/_config.js index 1586df8a79e9..fb1aa7f46aaf 100644 --- a/test/runtime/samples/custom-method/_config.js +++ b/test/runtime/samples/custom-method/_config.js @@ -5,11 +5,11 @@ export default { const event = new window.MouseEvent( 'click' ); button.dispatchEvent( event ); - assert.equal( component.get( 'counter' ), 1 ); + assert.equal( component.get().counter, 1 ); assert.equal( target.innerHTML, '\n\n

1

' ); button.dispatchEvent( event ); - assert.equal( component.get( 'counter' ), 2 ); + assert.equal( component.get().counter, 2 ); assert.equal( target.innerHTML, '\n\n

2

' ); assert.equal( component.foo(), 42 ); diff --git a/test/runtime/samples/custom-method/main.html b/test/runtime/samples/custom-method/main.html index 06ad01ca7962..3bd8459fb1fa 100644 --- a/test/runtime/samples/custom-method/main.html +++ b/test/runtime/samples/custom-method/main.html @@ -10,7 +10,7 @@ methods: { add1 () { - this.set({ counter: this.get( 'counter' ) + 1 }); + this.set({ counter: this.get().counter + 1 }); }, foo () { diff --git a/test/runtime/samples/deconflict-builtins/_config.js b/test/runtime/samples/deconflict-builtins/_config.js index 5ad7a4421060..debcfeaa139d 100644 --- a/test/runtime/samples/deconflict-builtins/_config.js +++ b/test/runtime/samples/deconflict-builtins/_config.js @@ -2,7 +2,7 @@ export default { html: `got`, test ( assert, component ) { - assert.equal( component.get( 'foo' ), 'got' ); + assert.equal( component.get().foo, 'got' ); component.destroy(); } }; \ No newline at end of file diff --git a/test/runtime/samples/deconflict-non-helpers/_config.js b/test/runtime/samples/deconflict-non-helpers/_config.js index 978e4c27e321..51670f56fead 100644 --- a/test/runtime/samples/deconflict-non-helpers/_config.js +++ b/test/runtime/samples/deconflict-non-helpers/_config.js @@ -2,7 +2,7 @@ export default { html: `ABCD`, test ( assert, component ) { - assert.equal( component.get( 'compute' ), 'ABCD' ); + assert.equal( component.get().compute, 'ABCD' ); component.destroy(); } }; diff --git a/test/runtime/samples/dev-warning-bad-observe-arguments/_config.js b/test/runtime/samples/dev-warning-bad-observe-arguments/_config.js deleted file mode 100644 index 0b9183aeba49..000000000000 --- a/test/runtime/samples/dev-warning-bad-observe-arguments/_config.js +++ /dev/null @@ -1,7 +0,0 @@ -export default { - dev: true, - - error ( assert, err ) { - assert.equal( err.message, `The first argument to component.observe(...) must be the name of a top-level property, i.e. 'nested' rather than 'nested.data'` ); - } -}; \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-bad-observe-arguments/main.html b/test/runtime/samples/dev-warning-bad-observe-arguments/main.html deleted file mode 100644 index e15ae99fa4d7..000000000000 --- a/test/runtime/samples/dev-warning-bad-observe-arguments/main.html +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/_config.js b/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/_config.js deleted file mode 100644 index 59c583ba1a93..000000000000 --- a/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/_config.js +++ /dev/null @@ -1,7 +0,0 @@ -export default { - dev: true, - - warnings: [ - `Return 'destroy()' from custom event handlers. Returning 'teardown()' has been deprecated and will be unsupported in Svelte 2` - ] -}; \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/main.html b/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/main.html deleted file mode 100644 index 1e83835f0324..000000000000 --- a/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/main.html +++ /dev/null @@ -1,16 +0,0 @@ - - - \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-destroy-not-teardown/_config.js b/test/runtime/samples/dev-warning-destroy-not-teardown/_config.js deleted file mode 100644 index 7e9b391f4ba5..000000000000 --- a/test/runtime/samples/dev-warning-destroy-not-teardown/_config.js +++ /dev/null @@ -1,7 +0,0 @@ -export default { - dev: true, - - warnings: [ - `Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2` - ] -}; \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-destroy-not-teardown/main.html b/test/runtime/samples/dev-warning-destroy-not-teardown/main.html deleted file mode 100644 index 22c2e9c28760..000000000000 --- a/test/runtime/samples/dev-warning-destroy-not-teardown/main.html +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings/_config.js b/test/runtime/samples/dynamic-component-bindings/_config.js index b10e1d720b2f..28ffc1664d72 100644 --- a/test/runtime/samples/dynamic-component-bindings/_config.js +++ b/test/runtime/samples/dynamic-component-bindings/_config.js @@ -13,7 +13,7 @@ export default { input.value = 'abc'; input.dispatchEvent(new window.Event('input')); - assert.equal(component.get('y'), 'abc'); + assert.equal(component.get().y, 'abc'); component.set({ x: false @@ -28,6 +28,6 @@ export default { input.checked = true; input.dispatchEvent(new window.Event('change')); - assert.equal(component.get('z'), true); + assert.equal(component.get().z, true); } }; \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-events/_config.js b/test/runtime/samples/dynamic-component-events/_config.js index 3315382e9166..b125e4078b30 100644 --- a/test/runtime/samples/dynamic-component-events/_config.js +++ b/test/runtime/samples/dynamic-component-events/_config.js @@ -11,7 +11,7 @@ export default { const click = new window.MouseEvent('click'); target.querySelector('button').dispatchEvent(click); - assert.equal(component.get('selected'), 'foo'); + assert.equal(component.get().selected, 'foo'); component.set({ x: false @@ -22,6 +22,6 @@ export default { `); target.querySelector('button').dispatchEvent(click); - assert.equal(component.get('selected'), 'bar'); + assert.equal(component.get().selected, 'bar'); } }; \ No newline at end of file diff --git a/test/runtime/samples/each-block-array-literal/_config.js b/test/runtime/samples/each-block-array-literal/_config.js index bc36cdbe0e5f..b7548f0d9b0c 100644 --- a/test/runtime/samples/each-block-array-literal/_config.js +++ b/test/runtime/samples/each-block-array-literal/_config.js @@ -14,6 +14,6 @@ export default { const event = new window.MouseEvent('click'); button.dispatchEvent(event); - assert.equal(component.get('clicked'), 'racoon'); + assert.equal(component.get().clicked, 'racoon'); }, }; diff --git a/test/runtime/samples/each-block-containing-if/_config.js b/test/runtime/samples/each-block-containing-if/_config.js index 778c5ccdfafe..cdb3d7e62cbc 100644 --- a/test/runtime/samples/each-block-containing-if/_config.js +++ b/test/runtime/samples/each-block-containing-if/_config.js @@ -1,6 +1,6 @@ export default { test ( assert, component, target ) { - const items = component.get( 'items' ); + const items = component.get().items; items.forEach( item => item.completed = false ); component.set({ currentFilter: 'all' }); diff --git a/test/runtime/samples/event-handler-custom-context/main.html b/test/runtime/samples/event-handler-custom-context/main.html index 806f330d6ce1..90e5a4c72e01 100644 --- a/test/runtime/samples/event-handler-custom-context/main.html +++ b/test/runtime/samples/event-handler-custom-context/main.html @@ -11,14 +11,14 @@ tap ( node, callback ) { const clickHandler = event => { callback({ - answer: this.get( 'answer' ) + answer: this.get().answer }); }; node.addEventListener( 'click', clickHandler, false ); return { - teardown () { + destroy () { node.addEventListener( 'click', clickHandler, false ); } }; diff --git a/test/runtime/samples/event-handler-custom-each-destructured/_config.js b/test/runtime/samples/event-handler-custom-each-destructured/_config.js index 9373d4dfee25..101268637e5d 100644 --- a/test/runtime/samples/event-handler-custom-each-destructured/_config.js +++ b/test/runtime/samples/event-handler-custom-each-destructured/_config.js @@ -24,8 +24,8 @@ export default {

second: bar

` ); - assert.equal( component.get( 'first' ), '1' ); - assert.equal( component.get( 'second' ), 'bar' ); + assert.equal( component.get().first, '1' ); + assert.equal( component.get().second, 'bar' ); component.destroy(); } diff --git a/test/runtime/samples/event-handler-custom-each-destructured/main.html b/test/runtime/samples/event-handler-custom-each-destructured/main.html index 6c5f24455dac..ae9251269d6f 100644 --- a/test/runtime/samples/event-handler-custom-each-destructured/main.html +++ b/test/runtime/samples/event-handler-custom-each-destructured/main.html @@ -26,7 +26,7 @@ node.addEventListener( 'click', clickHandler, false ); return { - teardown () { + destroy () { node.addEventListener( 'click', clickHandler, false ); } }; diff --git a/test/runtime/samples/event-handler-custom-each/_config.js b/test/runtime/samples/event-handler-custom-each/_config.js index 5d67fb14137b..e32876605e1d 100644 --- a/test/runtime/samples/event-handler-custom-each/_config.js +++ b/test/runtime/samples/event-handler-custom-each/_config.js @@ -24,8 +24,8 @@ export default {

fromState: bar

` ); - assert.equal( component.get( 'fromDom' ), 'bar' ); - assert.equal( component.get( 'fromState' ), 'bar' ); + assert.equal( component.get().fromDom, 'bar' ); + assert.equal( component.get().fromState, 'bar' ); component.destroy(); } diff --git a/test/runtime/samples/event-handler-custom-each/main.html b/test/runtime/samples/event-handler-custom-each/main.html index eb8a4d292cc6..309e5c96eedf 100644 --- a/test/runtime/samples/event-handler-custom-each/main.html +++ b/test/runtime/samples/event-handler-custom-each/main.html @@ -24,7 +24,7 @@ node.addEventListener( 'click', clickHandler, false ); return { - teardown () { + destroy () { node.addEventListener( 'click', clickHandler, false ); } }; diff --git a/test/runtime/samples/event-handler-custom-node-context/main.html b/test/runtime/samples/event-handler-custom-node-context/main.html index 916001d82c9b..1634d51719b9 100644 --- a/test/runtime/samples/event-handler-custom-node-context/main.html +++ b/test/runtime/samples/event-handler-custom-node-context/main.html @@ -15,7 +15,7 @@ node.addEventListener( 'click', clickHandler, false ); return { - teardown () { + destroy () { node.addEventListener( 'click', clickHandler, false ); } }; diff --git a/test/runtime/samples/event-handler-custom/main.html b/test/runtime/samples/event-handler-custom/main.html index b56b4f403b9b..949fafd72715 100644 --- a/test/runtime/samples/event-handler-custom/main.html +++ b/test/runtime/samples/event-handler-custom/main.html @@ -19,7 +19,7 @@ node.addEventListener( 'click', clickHandler, false ); return { - teardown () { + destroy () { node.addEventListener( 'click', clickHandler, false ); } }; diff --git a/test/runtime/samples/event-handler-each-deconflicted/_config.js b/test/runtime/samples/event-handler-each-deconflicted/_config.js index 0c11a15d3df4..13690a4e6266 100644 --- a/test/runtime/samples/event-handler-each-deconflicted/_config.js +++ b/test/runtime/samples/event-handler-each-deconflicted/_config.js @@ -16,7 +16,7 @@ export default { const event = new window.MouseEvent( 'click' ); buttons[0].dispatchEvent( event ); - assert.equal( component.get( 'clicked' ), 'foo' ); + assert.equal( component.get().clicked, 'foo' ); assert.htmlEqual( target.innerHTML, ` @@ -24,7 +24,7 @@ export default { ` ); buttons[1].dispatchEvent( event ); - assert.equal( component.get( 'clicked' ), 'bar' ); + assert.equal( component.get().clicked, 'bar' ); assert.htmlEqual( target.innerHTML, ` diff --git a/test/runtime/samples/event-handler-event-methods/_config.js b/test/runtime/samples/event-handler-event-methods/_config.js index 8b701e9825c5..50c0c08bd5e1 100644 --- a/test/runtime/samples/event-handler-event-methods/_config.js +++ b/test/runtime/samples/event-handler-event-methods/_config.js @@ -6,7 +6,7 @@ export default { allow.dispatchEvent( new window.MouseEvent( 'click', { bubbles: true }) ); stop.dispatchEvent( new window.MouseEvent( 'click', { bubbles: true }) ); - assert.equal( component.get( 'foo' ), true ); - assert.equal( component.get( 'bar' ), false ); + assert.equal( component.get().foo, true ); + assert.equal( component.get().bar, false ); } }; diff --git a/test/runtime/samples/event-handler-removal/_config.js b/test/runtime/samples/event-handler-removal/_config.js index b196db176599..474b6ef63e48 100644 --- a/test/runtime/samples/event-handler-removal/_config.js +++ b/test/runtime/samples/event-handler-removal/_config.js @@ -7,13 +7,13 @@ export default { // this should NOT trigger blur event component.set({ visible: false }); - assert.ok( !component.get( 'blurred' ) ); + assert.ok( !component.get().blurred ); component.set({ visible: true }); component.refs.input.focus(); // this SHOULD trigger blur event component.refs.input.blur(); - assert.ok( component.get( 'blurred' ) ); + assert.ok( component.get().blurred ); } }; diff --git a/test/runtime/samples/flush-before-bindings/_config.js b/test/runtime/samples/flush-before-bindings/_config.js index 1f731d6a34c3..066f3cb2c4c0 100644 --- a/test/runtime/samples/flush-before-bindings/_config.js +++ b/test/runtime/samples/flush-before-bindings/_config.js @@ -9,7 +9,7 @@ export default { `, test(assert, component) { - const visibleThings = component.get('visibleThings'); + const visibleThings = component.get().visibleThings; assert.deepEqual(visibleThings, ['first thing', 'second thing']); const snapshots = component.snapshots; diff --git a/test/runtime/samples/flush-before-bindings/main.html b/test/runtime/samples/flush-before-bindings/main.html index b078cffc8cb2..e95670f85d8c 100644 --- a/test/runtime/samples/flush-before-bindings/main.html +++ b/test/runtime/samples/flush-before-bindings/main.html @@ -14,11 +14,15 @@ Nested }, - oncreate() { - this.snapshots = []; - this.observe('visibleThings', things => { - this.snapshots.push(things); - }); + onstate({ current, changed, previous }) { + if (!this.snapshots) { + // first run + this.snapshots = []; + } + + if (changed.visibleThings) { + this.snapshots.push(current.visibleThings); + } } }; \ No newline at end of file diff --git a/test/runtime/samples/get-state/_config.js b/test/runtime/samples/get-state/_config.js index dd0b72fb16af..3c2dae5a815d 100644 --- a/test/runtime/samples/get-state/_config.js +++ b/test/runtime/samples/get-state/_config.js @@ -1,7 +1,7 @@ export default { test ( assert, component ) { - assert.equal( component.get('a'), 1 ); - assert.equal( component.get('c'), 3 ); + assert.equal( component.get().a, 1 ); + assert.equal( component.get().c, 3 ); assert.deepEqual( component.get(), { a: 1, b: 2, c: 3 }); } }; diff --git a/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js b/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js index a10750e1a035..cf15f47d9d3d 100644 --- a/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js +++ b/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js @@ -40,7 +40,7 @@ export default { input.checked = true; input.dispatchEvent(change); - assert.ok(component.get('todos').third.done); + assert.ok(component.get().todos.third.done); assert.htmlEqual(target.innerHTML, `
diff --git a/test/runtime/samples/immutable-mutable/Nested.html b/test/runtime/samples/immutable-mutable/Nested.html index 02278e385efd..f23d8f4257e9 100644 --- a/test/runtime/samples/immutable-mutable/Nested.html +++ b/test/runtime/samples/immutable-mutable/Nested.html @@ -1,13 +1,13 @@

Called {{count}} times.

\ No newline at end of file diff --git a/test/runtime/samples/immutable-mutable/_config.js b/test/runtime/samples/immutable-mutable/_config.js index 5dab0f239b20..d7381a38a247 100644 --- a/test/runtime/samples/immutable-mutable/_config.js +++ b/test/runtime/samples/immutable-mutable/_config.js @@ -4,13 +4,15 @@ export default { test(assert, component, target, window) { var nested = component.refs.nested; - nested.observe('foo', foo => { - nested.set({ count: nested.get('count') + 1 }); + nested.on('state', ({ changed }) => { + if (changed.foo) { + nested.set({ count: nested.get().count + 1 }); + } }); - assert.htmlEqual(target.innerHTML, `

Called 1 times.

`); + assert.htmlEqual(target.innerHTML, `

Called 0 times.

`); - nested.set({ foo: nested.get('foo') }); - assert.htmlEqual(target.innerHTML, `

Called 2 times.

`); + nested.set({ foo: nested.get().foo }); + assert.htmlEqual(target.innerHTML, `

Called 1 times.

`); } }; diff --git a/test/runtime/samples/immutable-nested/_config.js b/test/runtime/samples/immutable-nested/_config.js index 541566ce4dd8..1268a4a98855 100644 --- a/test/runtime/samples/immutable-nested/_config.js +++ b/test/runtime/samples/immutable-nested/_config.js @@ -4,13 +4,15 @@ export default { test(assert, component, target, window) { var nested = component.refs.nested; - nested.observe('foo', foo => { - nested.set({ count: nested.get('count') + 1 }); + nested.on('state', ({ changed }) => { + if (changed.foo) { + nested.set({ count: nested.get().count + 1 }); + } }); - assert.htmlEqual(target.innerHTML, `

Called 1 times.

`); + assert.htmlEqual(target.innerHTML, `

Called 0 times.

`); - nested.set({ foo: nested.get('foo') }); - assert.htmlEqual(target.innerHTML, `

Called 1 times.

`); + nested.set({ foo: nested.get().foo }); + assert.htmlEqual(target.innerHTML, `

Called 0 times.

`); } }; diff --git a/test/runtime/samples/immutable-root/_config.js b/test/runtime/samples/immutable-root/_config.js index a862008d7dfb..ab0b4287d8cb 100644 --- a/test/runtime/samples/immutable-root/_config.js +++ b/test/runtime/samples/immutable-root/_config.js @@ -3,13 +3,15 @@ export default { html: `

Called 0 times.

`, test(assert, component, target, window) { - component.observe('foo', foo => { - component.set({ count: component.get('count') + 1 }); + component.on('state', ({ changed }) => { + if (changed.foo) { + component.set({ count: component.get().count + 1 }); + } }); - assert.htmlEqual(target.innerHTML, `

Called 1 times.

`); + assert.htmlEqual(target.innerHTML, `

Called 0 times.

`); - component.set({ foo: component.get('foo') }); - assert.htmlEqual(target.innerHTML, `

Called 1 times.

`); + component.set({ foo: component.get().foo }); + assert.htmlEqual(target.innerHTML, `

Called 0 times.

`); } }; diff --git a/test/runtime/samples/observe-binding-ignores-unchanged/_config.js b/test/runtime/samples/observe-binding-ignores-unchanged/_config.js index 927572e7354c..04fee0d94ea6 100644 --- a/test/runtime/samples/observe-binding-ignores-unchanged/_config.js +++ b/test/runtime/samples/observe-binding-ignores-unchanged/_config.js @@ -7,9 +7,9 @@ export default { test(assert, component, target, window) { let triggered = false; - component.refs.nested.observe('field2', () => { - triggered = true; - }, { init: false }); + component.refs.nested.on('state', ({ changed }) => { + if (changed.field2) triggered = true; + }); const input = target.querySelector('input'); const event = new window.Event('input'); diff --git a/test/runtime/samples/observe-component-ignores-irrelevant-changes/_config.js b/test/runtime/samples/observe-component-ignores-irrelevant-changes/_config.js index 88be0160bd44..f14d044a1948 100644 --- a/test/runtime/samples/observe-component-ignores-irrelevant-changes/_config.js +++ b/test/runtime/samples/observe-component-ignores-irrelevant-changes/_config.js @@ -1,15 +1,15 @@ export default { - test ( assert, component ) { + test(assert, component) { const foo = component.refs.foo; let count = 0; - foo.observe( 'x', () => { - count += 1; + foo.on('state', ({ changed }) => { + if (changed.foo) count += 1; }); - assert.equal( count, 1 ); + assert.equal(count, 0); component.set({ y: {} }); - assert.equal( count, 1 ); + assert.equal(count, 0); } }; diff --git a/test/runtime/samples/observe-deferred/main.html b/test/runtime/samples/observe-deferred/main.html index 365d427f4da7..4ef322ab422d 100644 --- a/test/runtime/samples/observe-deferred/main.html +++ b/test/runtime/samples/observe-deferred/main.html @@ -3,11 +3,11 @@ \ No newline at end of file diff --git a/test/runtime/samples/onrender-chain/Item.html b/test/runtime/samples/onrender-chain/Item.html index b75cd0ca2366..4eb126062b03 100644 --- a/test/runtime/samples/onrender-chain/Item.html +++ b/test/runtime/samples/onrender-chain/Item.html @@ -2,15 +2,13 @@ + \ No newline at end of file diff --git a/test/runtime/samples/select-bind-in-array/_config.js b/test/runtime/samples/select-bind-in-array/_config.js index 609fc4592ad9..32b522982b60 100644 --- a/test/runtime/samples/select-bind-in-array/_config.js +++ b/test/runtime/samples/select-bind-in-array/_config.js @@ -8,7 +8,7 @@ export default { }, test ( assert, component, target ) { - const items = component.get('items'); + const items = component.get().items; assert.equal( items[0].id, 'a' ); assert.equal( items[1].id, 'b' ); diff --git a/test/runtime/samples/select-change-handler/_config.js b/test/runtime/samples/select-change-handler/_config.js index 015c8182b41c..8ea4d66e8237 100644 --- a/test/runtime/samples/select-change-handler/_config.js +++ b/test/runtime/samples/select-change-handler/_config.js @@ -14,8 +14,8 @@ export default { select.dispatchEvent( event ); assert.equal( select.value, 'c' ); - assert.equal( component.get( 'lastChangedTo' ), 'c' ); - assert.equal( component.get( 'selected' ), 'c' ); + assert.equal( component.get().lastChangedTo, 'c' ); + assert.equal( component.get().selected, 'c' ); component.destroy(); } diff --git a/test/runtime/samples/select-props/_config.js b/test/runtime/samples/select-props/_config.js index 1d4d39009477..0f93196cf766 100644 --- a/test/runtime/samples/select-props/_config.js +++ b/test/runtime/samples/select-props/_config.js @@ -10,6 +10,6 @@ export default { selects[1].value = 'b'; selects[1].dispatchEvent(event2); - assert.deepEqual( component.get( 'log' ), [ 1, 2 ] ); + assert.deepEqual( component.get().log, [ 1, 2 ] ); } }; diff --git a/test/runtime/samples/set-in-observe-dedupes-renders/Widget.html b/test/runtime/samples/set-in-observe-dedupes-renders/Widget.html deleted file mode 100644 index 3d414dd2043b..000000000000 --- a/test/runtime/samples/set-in-observe-dedupes-renders/Widget.html +++ /dev/null @@ -1,17 +0,0 @@ -
{{foo.x}}
- - diff --git a/test/runtime/samples/set-in-ondestroy/_config.js b/test/runtime/samples/set-in-ondestroy/_config.js index bc2212b03274..9923ebeb58fc 100644 --- a/test/runtime/samples/set-in-ondestroy/_config.js +++ b/test/runtime/samples/set-in-ondestroy/_config.js @@ -11,16 +11,16 @@ export default { component.on('destroy', () => { component.set({ foo: 2 }); - valueOnDestroy = component.get('foo'); + valueOnDestroy = component.get().foo; }); - component.observe('foo', foo => { - values.push(foo); + component.on('state', ({ current }) => { + values.push(current.foo); }); component.destroy(); - assert.deepEqual(values, [1, 2]); + assert.deepEqual(values, [2]); assert.equal(valueOnDestroy, 2); } }; diff --git a/test/runtime/samples/set-in-onstate-dedupes-renders/Widget.html b/test/runtime/samples/set-in-onstate-dedupes-renders/Widget.html new file mode 100644 index 000000000000..3d64f43effa2 --- /dev/null +++ b/test/runtime/samples/set-in-onstate-dedupes-renders/Widget.html @@ -0,0 +1,13 @@ +
{{foo.x}}
+ + \ No newline at end of file diff --git a/test/runtime/samples/set-in-observe-dedupes-renders/_config.js b/test/runtime/samples/set-in-onstate-dedupes-renders/_config.js similarity index 100% rename from test/runtime/samples/set-in-observe-dedupes-renders/_config.js rename to test/runtime/samples/set-in-onstate-dedupes-renders/_config.js diff --git a/test/runtime/samples/set-in-observe-dedupes-renders/main.html b/test/runtime/samples/set-in-onstate-dedupes-renders/main.html similarity index 69% rename from test/runtime/samples/set-in-observe-dedupes-renders/main.html rename to test/runtime/samples/set-in-onstate-dedupes-renders/main.html index f62940a4732c..2f621f33d0b8 100644 --- a/test/runtime/samples/set-in-observe-dedupes-renders/main.html +++ b/test/runtime/samples/set-in-onstate-dedupes-renders/main.html @@ -11,10 +11,10 @@ } }, - oncreate () { - this.observe( 'foo', foo => { - this.set({ bar: foo }); - }); + onstate({ changed, current }) { + if (changed.foo) { + this.set({ bar: current.foo }); + } }, components: { diff --git a/test/runtime/samples/set-in-observe/_config.js b/test/runtime/samples/set-in-onstate/_config.js similarity index 100% rename from test/runtime/samples/set-in-observe/_config.js rename to test/runtime/samples/set-in-onstate/_config.js diff --git a/test/runtime/samples/set-in-observe/main.html b/test/runtime/samples/set-in-onstate/main.html similarity index 52% rename from test/runtime/samples/set-in-observe/main.html rename to test/runtime/samples/set-in-onstate/main.html index d07607f5fec8..7446198502ec 100644 --- a/test/runtime/samples/set-in-observe/main.html +++ b/test/runtime/samples/set-in-onstate/main.html @@ -7,10 +7,10 @@ foo: 1 }), - oncreate () { - this.observe( 'foo', foo => { - this.set({ bar: foo * 2 }); - }); + onstate({ changed, current }) { + if (changed.foo) { + this.set({ bar: current.foo * 2 }); + } } }; diff --git a/test/runtime/samples/store-binding/_config.js b/test/runtime/samples/store-binding/_config.js index aefc4ec652ac..7839a9e3ea5f 100644 --- a/test/runtime/samples/store-binding/_config.js +++ b/test/runtime/samples/store-binding/_config.js @@ -19,7 +19,7 @@ export default { input.value = 'everybody'; input.dispatchEvent(event); - assert.equal(store.get('name'), 'everybody'); + assert.equal(store.get().name, 'everybody'); assert.htmlEqual(target.innerHTML, `

Hello everybody!

diff --git a/test/runtime/samples/store-component-binding-deep/_config.js b/test/runtime/samples/store-component-binding-deep/_config.js index 66ae5ac4ae22..e5f0b43156cc 100644 --- a/test/runtime/samples/store-component-binding-deep/_config.js +++ b/test/runtime/samples/store-component-binding-deep/_config.js @@ -19,14 +19,14 @@ export default { const event = new window.Event('input'); const changeRecord = []; - store.onchange((state, changes) => { - changeRecord.push({ state, changes }); + store.on('state', ({ changed, current }) => { + changeRecord.push({ changed, current }); }); input.value = 'everybody'; input.dispatchEvent(event); - assert.equal(store.get('name').value, 'everybody'); + assert.equal(store.get().name.value, 'everybody'); assert.htmlEqual(target.innerHTML, `

Hello everybody!

@@ -34,8 +34,8 @@ export default { assert.deepEqual(changeRecord, [ { - state: { name: { value: 'everybody' } }, - changes: { name: true } + current: { name: { value: 'everybody' } }, + changed: { name: true } } ]); } diff --git a/test/runtime/samples/store-component-binding-each/_config.js b/test/runtime/samples/store-component-binding-each/_config.js index 5d6e6889aef2..84977b9b3b68 100644 --- a/test/runtime/samples/store-component-binding-each/_config.js +++ b/test/runtime/samples/store-component-binding-each/_config.js @@ -19,7 +19,7 @@ export default { inputs[0].value = 'blah'; inputs[0].dispatchEvent(event); - assert.deepEqual(store.get('a'), ['blah', 'bar', 'baz']); + assert.deepEqual(store.get().a, ['blah', 'bar', 'baz']); assert.htmlEqual(target.innerHTML, `

blah, bar, baz

diff --git a/test/runtime/samples/store-component-binding/_config.js b/test/runtime/samples/store-component-binding/_config.js index 1d2beab7a778..12b0fcbfb41d 100644 --- a/test/runtime/samples/store-component-binding/_config.js +++ b/test/runtime/samples/store-component-binding/_config.js @@ -17,14 +17,14 @@ export default { const event = new window.Event('input'); const changeRecord = []; - store.onchange((state, changes) => { - changeRecord.push({ state, changes }); + store.on('state', ({ changed, current }) => { + changeRecord.push({ changed, current }); }); input.value = 'everybody'; input.dispatchEvent(event); - assert.equal(store.get('name'), 'everybody'); + assert.equal(store.get().name, 'everybody'); assert.htmlEqual(target.innerHTML, `

Hello everybody!

@@ -32,8 +32,8 @@ export default { assert.deepEqual(changeRecord, [ { - state: { name: 'everybody' }, - changes: { name: true } + current: { name: 'everybody' }, + changed: { name: true } } ]); } diff --git a/test/runtime/samples/store-computed/_config.js b/test/runtime/samples/store-computed/_config.js index f4e6f49e5454..f922a55738c2 100644 --- a/test/runtime/samples/store-computed/_config.js +++ b/test/runtime/samples/store-computed/_config.js @@ -7,7 +7,7 @@ class MyStore extends Store { toggleTodo(todo) { todo.done = !todo.done; - this.set({ todos: this.get('todos') }); + this.set({ todos: this.get().todos }); } } diff --git a/test/runtime/samples/store-event/_config.js b/test/runtime/samples/store-event/_config.js index 2779db5fc270..58afa156115d 100644 --- a/test/runtime/samples/store-event/_config.js +++ b/test/runtime/samples/store-event/_config.js @@ -25,7 +25,7 @@ export default { input.value = 'everybody'; input.dispatchEvent(event); - assert.equal(store.get('name'), 'everybody'); + assert.equal(store.get().name, 'everybody'); assert.htmlEqual(target.innerHTML, `

Hello everybody!

diff --git a/test/runtime/samples/window-event-context/_config.js b/test/runtime/samples/window-event-context/_config.js index ac0fd953bf9d..f9e562aef602 100644 --- a/test/runtime/samples/window-event-context/_config.js +++ b/test/runtime/samples/window-event-context/_config.js @@ -12,11 +12,11 @@ export default { const event = new window.Event( 'click' ); window.dispatchEvent( event ); - assert.equal( component.get( 'foo' ), false ); + assert.equal( component.get().foo, false ); assert.htmlEqual( target.innerHTML, `false` ); window.dispatchEvent( event ); - assert.equal( component.get( 'foo' ), true ); + assert.equal( component.get().foo, true ); assert.htmlEqual( target.innerHTML, `true` ); component.destroy(); From df4e3678dcbea09f8188d48198ac3a6015d716cf Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 19:17:11 -0400 Subject: [PATCH 08/40] update snapshot tests --- src/generators/dom/index.ts | 2 +- test/js/samples/action/expected-bundle.js | 2 -- .../_actual-bundle-v2.js | 2 -- .../expected-bundle-v2.js | 2 -- .../expected-bundle.js | 2 -- .../component-static-immutable/expected-bundle.js | 2 -- .../expected-bundle.js | 2 -- .../samples/component-static/expected-bundle.js | 2 -- .../computed-collapsed-if/expected-bundle.js | 2 -- .../js/samples/css-media-query/expected-bundle.js | 2 -- .../css-shadow-dom-keyframes/expected-bundle.js | 2 -- .../deconflict-builtins/_actual-bundle-v2.js | 2 -- .../deconflict-builtins/expected-bundle-v2.js | 2 -- .../deconflict-builtins/expected-bundle.js | 2 -- .../samples/deconflict-globals/expected-bundle.js | 2 -- .../_actual-bundle-v2.js | 15 +-------------- .../expected-bundle-v2.js | 15 +-------------- .../expected-bundle.js | 15 +-------------- .../samples/do-use-dataset/_actual-bundle-v2.js | 2 -- .../samples/do-use-dataset/expected-bundle-v2.js | 2 -- test/js/samples/do-use-dataset/expected-bundle.js | 2 -- .../_actual-bundle-v2.js | 2 -- .../expected-bundle-v2.js | 2 -- .../dont-use-dataset-in-legacy/expected-bundle.js | 2 -- .../dont-use-dataset-in-svg/_actual-bundle-v2.js | 2 -- .../dont-use-dataset-in-svg/expected-bundle-v2.js | 2 -- .../dont-use-dataset-in-svg/expected-bundle.js | 2 -- .../each-block-changed-check/_actual-bundle-v2.js | 2 -- .../expected-bundle-v2.js | 2 -- .../each-block-changed-check/expected-bundle.js | 2 -- .../event-handlers-custom/expected-bundle.js | 4 +--- test/js/samples/event-handlers-custom/expected.js | 2 +- .../head-no-whitespace/_actual-bundle-v2.js | 2 -- .../head-no-whitespace/expected-bundle-v2.js | 2 -- .../samples/head-no-whitespace/expected-bundle.js | 2 -- .../if-block-no-update/_actual-bundle-v2.js | 2 -- .../if-block-no-update/expected-bundle-v2.js | 2 -- .../samples/if-block-no-update/expected-bundle.js | 2 -- .../samples/if-block-simple/_actual-bundle-v2.js | 2 -- .../samples/if-block-simple/expected-bundle-v2.js | 2 -- .../js/samples/if-block-simple/expected-bundle.js | 2 -- .../_actual-bundle-v2.js | 2 -- .../expected-bundle-v2.js | 2 -- .../expected-bundle.js | 2 -- .../_actual-bundle-v2.js | 2 -- .../expected-bundle-v2.js | 2 -- .../inline-style-optimized-url/expected-bundle.js | 2 -- .../inline-style-optimized/_actual-bundle-v2.js | 2 -- .../inline-style-optimized/expected-bundle-v2.js | 2 -- .../inline-style-optimized/expected-bundle.js | 2 -- .../inline-style-unoptimized/_actual-bundle-v2.js | 2 -- .../expected-bundle-v2.js | 2 -- .../inline-style-unoptimized/expected-bundle.js | 2 -- .../expected-bundle.js | 2 -- test/js/samples/legacy-default/expected-bundle.js | 2 -- .../samples/legacy-input-type/expected-bundle.js | 2 -- .../samples/legacy-quote-class/expected-bundle.js | 2 -- test/js/samples/media-bindings/expected-bundle.js | 2 -- .../non-imported-component/expected-bundle.js | 2 -- .../expected-bundle.js | 2 -- test/js/samples/setup-method/expected-bundle.js | 2 -- test/js/samples/svg-title/expected-bundle.js | 2 -- test/js/samples/title/_actual-bundle-v2.js | 2 -- test/js/samples/title/expected-bundle-v2.js | 2 -- test/js/samples/title/expected-bundle.js | 2 -- .../use-elements-as-anchors/_actual-bundle-v2.js | 2 -- .../use-elements-as-anchors/expected-bundle-v2.js | 2 -- .../use-elements-as-anchors/expected-bundle.js | 2 -- .../window-binding-scroll/_actual-bundle-v2.js | 2 -- .../window-binding-scroll/expected-bundle-v2.js | 2 -- .../window-binding-scroll/expected-bundle.js | 2 -- 71 files changed, 6 insertions(+), 177 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index e3bb7e669749..9b9d888cf6b9 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -294,7 +294,7 @@ export default function dom( ${props.map(prop => deindent` get ${prop}() { - return this.get('${prop}'); + return this.get().${prop}; } set ${prop}(value) { diff --git a/test/js/samples/action/expected-bundle.js b/test/js/samples/action/expected-bundle.js index c58cbdcea3a3..093fb642a768 100644 --- a/test/js/samples/action/expected-bundle.js +++ b/test/js/samples/action/expected-bundle.js @@ -65,8 +65,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/collapses-text-around-comments/_actual-bundle-v2.js b/test/js/samples/collapses-text-around-comments/_actual-bundle-v2.js index 1c6d4db78ab3..ed6fef0f3db7 100644 --- a/test/js/samples/collapses-text-around-comments/_actual-bundle-v2.js +++ b/test/js/samples/collapses-text-around-comments/_actual-bundle-v2.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle-v2.js b/test/js/samples/collapses-text-around-comments/expected-bundle-v2.js index 1c6d4db78ab3..ed6fef0f3db7 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle-v2.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle-v2.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle.js b/test/js/samples/collapses-text-around-comments/expected-bundle.js index 1c6d4db78ab3..ed6fef0f3db7 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js index 959b6fea5645..235f57755d3a 100644 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -57,8 +57,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js index 959b6fea5645..235f57755d3a 100644 --- a/test/js/samples/component-static-immutable2/expected-bundle.js +++ b/test/js/samples/component-static-immutable2/expected-bundle.js @@ -57,8 +57,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index b7f9dcbbb996..dc4f6dbf0dd9 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -53,8 +53,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 5ed48c2966bc..5347ce59a13c 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -53,8 +53,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index f4076b12139a..8802fe3002ed 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js index edf44bfd7a76..c2f35f7b986e 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -65,8 +65,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/deconflict-builtins/_actual-bundle-v2.js b/test/js/samples/deconflict-builtins/_actual-bundle-v2.js index e895d021e6f8..2f9dd2db1d49 100644 --- a/test/js/samples/deconflict-builtins/_actual-bundle-v2.js +++ b/test/js/samples/deconflict-builtins/_actual-bundle-v2.js @@ -83,8 +83,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/deconflict-builtins/expected-bundle-v2.js b/test/js/samples/deconflict-builtins/expected-bundle-v2.js index e895d021e6f8..2f9dd2db1d49 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle-v2.js +++ b/test/js/samples/deconflict-builtins/expected-bundle-v2.js @@ -83,8 +83,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js index 1e9eb4b70913..0bfddd1f0dee 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ b/test/js/samples/deconflict-builtins/expected-bundle.js @@ -83,8 +83,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index 8d23561dec85..214eed957865 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -53,8 +53,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js b/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js index c048d39b9949..e0ff6a11717d 100644 --- a/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js +++ b/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js @@ -80,8 +80,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -93,17 +91,6 @@ function on(eventName, handler) { }; } -function onDev(eventName, handler) { - if (eventName === 'teardown') { - console.warn( - "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2" - ); - return this.on('destroy', handler); - } - - return on.call(this, eventName, handler); -} - function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; @@ -162,7 +149,7 @@ var protoDev = { destroy: destroyDev, get, fire, - on: onDev, + on, set: setDev, _recompute: noop, _set, diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js index c048d39b9949..e0ff6a11717d 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js @@ -80,8 +80,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -93,17 +91,6 @@ function on(eventName, handler) { }; } -function onDev(eventName, handler) { - if (eventName === 'teardown') { - console.warn( - "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2" - ); - return this.on('destroy', handler); - } - - return on.call(this, eventName, handler); -} - function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; @@ -162,7 +149,7 @@ var protoDev = { destroy: destroyDev, get, fire, - on: onDev, + on, set: setDev, _recompute: noop, _set, diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js index ef60f3ec411c..effef47cb9a1 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js @@ -80,8 +80,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -93,17 +91,6 @@ function on(eventName, handler) { }; } -function onDev(eventName, handler) { - if (eventName === 'teardown') { - console.warn( - "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2" - ); - return this.on('destroy', handler); - } - - return on.call(this, eventName, handler); -} - function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; @@ -162,7 +149,7 @@ var protoDev = { destroy: destroyDev, get, fire, - on: onDev, + on, set: setDev, _recompute: noop, _set, diff --git a/test/js/samples/do-use-dataset/_actual-bundle-v2.js b/test/js/samples/do-use-dataset/_actual-bundle-v2.js index d16e73a4877f..32af7494c3df 100644 --- a/test/js/samples/do-use-dataset/_actual-bundle-v2.js +++ b/test/js/samples/do-use-dataset/_actual-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/do-use-dataset/expected-bundle-v2.js b/test/js/samples/do-use-dataset/expected-bundle-v2.js index d16e73a4877f..32af7494c3df 100644 --- a/test/js/samples/do-use-dataset/expected-bundle-v2.js +++ b/test/js/samples/do-use-dataset/expected-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js index d16e73a4877f..32af7494c3df 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js b/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js index 925c6e692b46..5e9def191391 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js +++ b/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js index 925c6e692b46..5e9def191391 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js index 925c6e692b46..5e9def191391 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js b/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js index 3ad8d8e9885e..54b8382a2db9 100644 --- a/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js +++ b/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js b/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js index 3ad8d8e9885e..54b8382a2db9 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js index 3ad8d8e9885e..54b8382a2db9 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/each-block-changed-check/_actual-bundle-v2.js b/test/js/samples/each-block-changed-check/_actual-bundle-v2.js index 5a2805c66951..89c3cab24320 100644 --- a/test/js/samples/each-block-changed-check/_actual-bundle-v2.js +++ b/test/js/samples/each-block-changed-check/_actual-bundle-v2.js @@ -85,8 +85,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/each-block-changed-check/expected-bundle-v2.js b/test/js/samples/each-block-changed-check/expected-bundle-v2.js index 5a2805c66951..89c3cab24320 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle-v2.js +++ b/test/js/samples/each-block-changed-check/expected-bundle-v2.js @@ -85,8 +85,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js index 80b5d1220ce5..846fea0ba702 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -85,8 +85,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 977e92dec656..5d85e177e1b4 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -65,8 +65,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -173,7 +171,7 @@ function create_main_fragment(component, state) { }, d: function destroy$$1() { - foo_handler[foo_handler.destroy ? 'destroy' : 'teardown'](); + foo_handler.destroy(); } }; } diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index bfec4474065d..3975641534d1 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -39,7 +39,7 @@ function create_main_fragment(component, state) { }, d: function destroy() { - foo_handler[foo_handler.destroy ? 'destroy' : 'teardown'](); + foo_handler.destroy(); } }; } diff --git a/test/js/samples/head-no-whitespace/_actual-bundle-v2.js b/test/js/samples/head-no-whitespace/_actual-bundle-v2.js index cb51aacad9d8..7f88574b70f6 100644 --- a/test/js/samples/head-no-whitespace/_actual-bundle-v2.js +++ b/test/js/samples/head-no-whitespace/_actual-bundle-v2.js @@ -65,8 +65,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/head-no-whitespace/expected-bundle-v2.js b/test/js/samples/head-no-whitespace/expected-bundle-v2.js index cb51aacad9d8..7f88574b70f6 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle-v2.js +++ b/test/js/samples/head-no-whitespace/expected-bundle-v2.js @@ -65,8 +65,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js index cb51aacad9d8..7f88574b70f6 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -65,8 +65,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/if-block-no-update/_actual-bundle-v2.js b/test/js/samples/if-block-no-update/_actual-bundle-v2.js index 12168d6294a4..1760a2ca607f 100644 --- a/test/js/samples/if-block-no-update/_actual-bundle-v2.js +++ b/test/js/samples/if-block-no-update/_actual-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/if-block-no-update/expected-bundle-v2.js b/test/js/samples/if-block-no-update/expected-bundle-v2.js index 12168d6294a4..1760a2ca607f 100644 --- a/test/js/samples/if-block-no-update/expected-bundle-v2.js +++ b/test/js/samples/if-block-no-update/expected-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js index 9f75086f359d..303bd8482128 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/if-block-simple/_actual-bundle-v2.js b/test/js/samples/if-block-simple/_actual-bundle-v2.js index 76e6919ebd4f..f71aafff9415 100644 --- a/test/js/samples/if-block-simple/_actual-bundle-v2.js +++ b/test/js/samples/if-block-simple/_actual-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/if-block-simple/expected-bundle-v2.js b/test/js/samples/if-block-simple/expected-bundle-v2.js index 76e6919ebd4f..f71aafff9415 100644 --- a/test/js/samples/if-block-simple/expected-bundle-v2.js +++ b/test/js/samples/if-block-simple/expected-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 676d6d0d4e13..7fe3bd33d7f8 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js index f15569295ab2..bd3bacfac27a 100644 --- a/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js +++ b/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js b/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js index f15569295ab2..bd3bacfac27a 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js index f15569295ab2..bd3bacfac27a 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js index 77130c71b326..411990568209 100644 --- a/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js +++ b/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js b/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js index 77130c71b326..411990568209 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-optimized-url/expected-bundle.js b/test/js/samples/inline-style-optimized-url/expected-bundle.js index 77130c71b326..411990568209 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-optimized/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized/_actual-bundle-v2.js index 1f444ef70485..7643ee066d12 100644 --- a/test/js/samples/inline-style-optimized/_actual-bundle-v2.js +++ b/test/js/samples/inline-style-optimized/_actual-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-optimized/expected-bundle-v2.js b/test/js/samples/inline-style-optimized/expected-bundle-v2.js index 1f444ef70485..7643ee066d12 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle-v2.js +++ b/test/js/samples/inline-style-optimized/expected-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js index 1f444ef70485..7643ee066d12 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js b/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js index 8ce9a079cdd5..67b27347432a 100644 --- a/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js +++ b/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js b/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js index 8ce9a079cdd5..67b27347432a 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js index 8ce9a079cdd5..67b27347432a 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -69,8 +69,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/input-without-blowback-guard/expected-bundle.js b/test/js/samples/input-without-blowback-guard/expected-bundle.js index f81413a0fcb5..e881aa6de460 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -77,8 +77,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/legacy-default/expected-bundle.js b/test/js/samples/legacy-default/expected-bundle.js index 9c444e4097fc..d4c2199ca9c9 100644 --- a/test/js/samples/legacy-default/expected-bundle.js +++ b/test/js/samples/legacy-default/expected-bundle.js @@ -87,8 +87,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index 67be76877345..1119454b3db6 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -71,8 +71,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/legacy-quote-class/expected-bundle.js b/test/js/samples/legacy-quote-class/expected-bundle.js index 4c44d15ccb9e..ffb11ab8f395 100644 --- a/test/js/samples/legacy-quote-class/expected-bundle.js +++ b/test/js/samples/legacy-quote-class/expected-bundle.js @@ -88,8 +88,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index 2926e5a5a072..abcdd409862d 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -81,8 +81,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index d6991d3b7265..b4adec303a0a 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -67,8 +67,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index de7133b48c28..0a9150961967 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -53,8 +53,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 8267343f1291..e1aaa9ae759a 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -53,8 +53,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index 6d67ee7a1de6..477d97c83947 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/title/_actual-bundle-v2.js b/test/js/samples/title/_actual-bundle-v2.js index cc4b9229c83c..27cae18b3d14 100644 --- a/test/js/samples/title/_actual-bundle-v2.js +++ b/test/js/samples/title/_actual-bundle-v2.js @@ -53,8 +53,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/title/expected-bundle-v2.js b/test/js/samples/title/expected-bundle-v2.js index cc4b9229c83c..27cae18b3d14 100644 --- a/test/js/samples/title/expected-bundle-v2.js +++ b/test/js/samples/title/expected-bundle-v2.js @@ -53,8 +53,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index cc4b9229c83c..27cae18b3d14 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -53,8 +53,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js b/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js index 26852a55406d..1fda063de122 100644 --- a/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js +++ b/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js @@ -77,8 +77,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js b/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js index 26852a55406d..1fda063de122 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js @@ -77,8 +77,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle.js b/test/js/samples/use-elements-as-anchors/expected-bundle.js index 451a9fb9b6ff..f0eea45d7743 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -77,8 +77,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/window-binding-scroll/_actual-bundle-v2.js b/test/js/samples/window-binding-scroll/_actual-bundle-v2.js index ef796382c4a0..deb99a4bb870 100644 --- a/test/js/samples/window-binding-scroll/_actual-bundle-v2.js +++ b/test/js/samples/window-binding-scroll/_actual-bundle-v2.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/window-binding-scroll/expected-bundle-v2.js b/test/js/samples/window-binding-scroll/expected-bundle-v2.js index ef796382c4a0..deb99a4bb870 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle-v2.js +++ b/test/js/samples/window-binding-scroll/expected-bundle-v2.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index ef796382c4a0..deb99a4bb870 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -73,8 +73,6 @@ function init(component, options) { } function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); From a3add04e7c7cd0b68ddf67c67e505a156e1d797b Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 19:34:42 -0400 Subject: [PATCH 09/40] remove code, map and cssMap from svelte.compile output --- src/generators/Generator.ts | 20 +------------------- src/index.ts | 4 ++-- src/server-side-rendering/register.js | 4 ++-- test/css/index.js | 18 +++++++++--------- test/custom-elements/index.js | 5 +---- test/formats/index.js | 24 ++++++++++++------------ test/hydration/index.js | 4 ++-- test/js/index.js | 2 +- test/runtime/index.js | 12 ++++++------ test/sourcemaps/index.js | 20 ++++++++++---------- 10 files changed, 46 insertions(+), 67 deletions(-) diff --git a/src/generators/Generator.ts b/src/generators/Generator.ts index 474b32a9c0ab..7565336abbfd 100644 --- a/src/generators/Generator.ts +++ b/src/generators/Generator.ts @@ -369,31 +369,13 @@ export default class Generator { }) }; - Object.getOwnPropertyNames(String.prototype).forEach(name => { - const descriptor = Object.getOwnPropertyDescriptor(String.prototype, name); - if (typeof descriptor.value === 'function') { - Object.defineProperty(css, name, { - value: (...args) => { - return css.code === null - ? null - : css.code[name].call(css.code, ...args); - } - }); - } - }); - this.stats.stop('compile'); return { ast: this.ast, js, css, - stats: this.stats.render(this), - - // TODO deprecate - code: js.code, - map: js.map, - cssMap: css.map + stats: this.stats.render(this) }; } diff --git a/src/index.ts b/src/index.ts index 16081ea8b4d3..d13d568069df 100644 --- a/src/index.ts +++ b/src/index.ts @@ -147,12 +147,12 @@ export function create(source: string, _options: CompileOptions = {}) { const compiled = compile(source, _options); - if (!compiled || !compiled.code) { + if (!compiled || !compiled.js.code) { return; } try { - return (0, eval)(compiled.code); + return (0, eval)(compiled.js.code); } catch (err) { if (_options.onerror) { _options.onerror(err); diff --git a/src/server-side-rendering/register.js b/src/server-side-rendering/register.js index 7940a2c4875f..75b10d29f943 100644 --- a/src/server-side-rendering/register.js +++ b/src/server-side-rendering/register.js @@ -37,9 +37,9 @@ function _register(extension) { generate: 'ssr' }); - const {code} = compile(fs.readFileSync(filename, 'utf-8'), options); + const { js } = compile(fs.readFileSync(filename, 'utf-8'), options); - return module._compile(code, filename); + return module._compile(js.code, filename); }; } diff --git a/test/css/index.js b/test/css/index.js index a59f13266054..8af76f61c130 100644 --- a/test/css/index.js +++ b/test/css/index.js @@ -78,10 +78,10 @@ describe('css', () => { ); // check the code is valid - checkCodeIsValid(dom.code); - checkCodeIsValid(ssr.code); + checkCodeIsValid(dom.js.code); + checkCodeIsValid(ssr.js.code); - assert.equal(dom.css.toString(), ssr.css.toString()); + assert.equal(dom.css.code, ssr.css.code); assert.deepEqual( domWarnings.map(normalizeWarning), @@ -89,13 +89,13 @@ describe('css', () => { ); assert.deepEqual(domWarnings.map(normalizeWarning), expectedWarnings); - fs.writeFileSync(`test/css/samples/${dir}/_actual.css`, dom.css); + fs.writeFileSync(`test/css/samples/${dir}/_actual.css`, dom.css.code); const expected = { html: read(`test/css/samples/${dir}/expected.html`), css: read(`test/css/samples/${dir}/expected.css`) }; - assert.equal(dom.css.replace(/svelte(-ref)?-[a-z0-9]+/g, (m, $1) => $1 ? m : 'svelte-xyz'), expected.css); + assert.equal(dom.css.code.replace(/svelte(-ref)?-[a-z0-9]+/g, (m, $1) => $1 ? m : 'svelte-xyz'), expected.css); // verify that the right elements have scoping selectors if (expected.html !== null) { @@ -104,7 +104,7 @@ describe('css', () => { // dom try { const Component = eval( - `(function () { ${dom.code}; return SvelteComponent; }())` + `(function () { ${dom.js.code}; return SvelteComponent; }())` ); const target = window.document.querySelector('main'); @@ -120,14 +120,14 @@ describe('css', () => { window.document.head.innerHTML = ''; // remove added styles } catch (err) { - console.log(dom.code); + console.log(dom.js.code); throw err; } // ssr try { const component = eval( - `(function () { ${ssr.code}; return SvelteComponent; }())` + `(function () { ${ssr.js.code}; return SvelteComponent; }())` ); assert.equal( @@ -138,7 +138,7 @@ describe('css', () => { normalizeHtml(window, expected.html) ); } catch (err) { - console.log(ssr.code); + console.log(ssr.js.code); throw err; } } diff --git a/test/custom-elements/index.js b/test/custom-elements/index.js index ab101dc873df..7675e0c188b6 100644 --- a/test/custom-elements/index.js +++ b/test/custom-elements/index.js @@ -70,10 +70,7 @@ describe('custom-elements', function() { dev: config.dev }); - return { - code: compiled.code, - map: compiled.map - }; + return compiled.js; } } }, diff --git a/test/formats/index.js b/test/formats/index.js index 2a8b47df535c..91b2d1dc33a5 100644 --- a/test/formats/index.js +++ b/test/formats/index.js @@ -98,12 +98,12 @@ describe("formats", () => { `; - const { code } = svelte.compile(source, { + const { js } = svelte.compile(source, { format: "amd", amd: { id: "foo" } }); - return testAmd(code, "foo", { answer: 42 }, `
42
`); + return testAmd(js.code, "foo", { answer: 42 }, `
42
`); }); }); @@ -123,11 +123,11 @@ describe("formats", () => { `; - const { code } = svelte.compile(source, { + const { js } = svelte.compile(source, { format: "cjs" }); - return testCjs(code, { answer: 42 }, `
42
`); + return testCjs(js.code, { answer: 42 }, `
42
`); }); }); @@ -147,7 +147,7 @@ describe("formats", () => { `; - const { code } = svelte.compile(source, { + const { js } = svelte.compile(source, { format: "iife", name: "Foo", globals: { @@ -155,7 +155,7 @@ describe("formats", () => { } }); - return testIife(code, "Foo", { answer: 42 }, `
42
`); + return testIife(js.code, "Foo", { answer: 42 }, `
42
`); }); it('requires options.name', () => { @@ -221,7 +221,7 @@ describe("formats", () => { `; - const { code } = svelte.compile(source, { + const { js } = svelte.compile(source, { format: "umd", name: "Foo", globals: { @@ -232,9 +232,9 @@ describe("formats", () => { } }); - testAmd(code, "foo", { answer: 42 }, `
42
`); - testCjs(code, { answer: 42 }, `
42
`); - testIife(code, "Foo", { answer: 42 }, `
42
`); + testAmd(js.code, "foo", { answer: 42 }, `
42
`); + testCjs(js.code, { answer: 42 }, `
42
`); + testIife(js.code, "Foo", { answer: 42 }, `
42
`); }); it('requires options.name', () => { @@ -262,14 +262,14 @@ describe("formats", () => { `; - const { code } = svelte.compile(source, { + const { js } = svelte.compile(source, { format: "eval", globals: { answer: "answer" } }); - return testEval(code, "Foo", { answer: 42 }, `
42
`); + return testEval(js.code, "Foo", { answer: 42 }, `
42
`); }); }); diff --git a/test/hydration/index.js b/test/hydration/index.js index 922ff23de8d1..81634ea1512c 100644 --- a/test/hydration/index.js +++ b/test/hydration/index.js @@ -27,9 +27,9 @@ describe('hydration', () => { compileOptions ); - const { code } = svelte.compile(fs.readFileSync(filename, 'utf-8'), options); + const { js } = svelte.compile(fs.readFileSync(filename, 'utf-8'), options); - return module._compile(code, filename); + return module._compile(js.code, filename); }; return setupHtmlEqual(); diff --git a/test/js/index.js b/test/js/index.js index ef2a05a09e72..6a254b16b450 100644 --- a/test/js/index.js +++ b/test/js/index.js @@ -28,7 +28,7 @@ describe("js", () => { parser: v2 ? 'v2' : 'v1' }); - actual = svelte.compile(input, options).code.replace(/generated by Svelte v\d+\.\d+\.\d+/, 'generated by Svelte vX.Y.Z'); + actual = svelte.compile(input, options).js.code.replace(/generated by Svelte v\d+\.\d+\.\d+/, 'generated by Svelte vX.Y.Z'); } catch (err) { console.log(err.frame); throw err; diff --git a/test/runtime/index.js b/test/runtime/index.js index b491dafa2071..96d7ad644555 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -36,9 +36,9 @@ describe("runtime", () => { compileOptions ); - const { code } = compile(fs.readFileSync(filename, "utf-8"), options); + const { js } = compile(fs.readFileSync(filename, "utf-8"), options); - return module._compile(code, filename); + return module._compile(js.code, filename); }; return setupHtmlEqual(); @@ -194,14 +194,14 @@ describe("runtime", () => { }); it("fails if options.target is missing in dev mode", () => { - const { code } = svelte$.compile(`
`, { + const { js } = svelte$.compile(`
`, { format: "iife", name: "SvelteComponent", dev: true }); const SvelteComponent = eval( - `(function () { ${code}; return SvelteComponent; }())` + `(function () { ${js.code}; return SvelteComponent; }())` ); assert.throws(() => { @@ -210,14 +210,14 @@ describe("runtime", () => { }); it("fails if options.hydrate is true but the component is non-hydratable", () => { - const { code } = svelte$.compile(`
`, { + const { js } = svelte$.compile(`
`, { format: "iife", name: "SvelteComponent", dev: true }); const SvelteComponent = eval( - `(function () { ${code}; return SvelteComponent; }())` + `(function () { ${js.code}; return SvelteComponent; }())` ); assert.throws(() => { diff --git a/test/sourcemaps/index.js b/test/sourcemaps/index.js index 9835f8ba3f27..59342cbe6fd8 100644 --- a/test/sourcemaps/index.js +++ b/test/sourcemaps/index.js @@ -27,14 +27,14 @@ describe("sourcemaps", () => { ); const input = fs.readFileSync(filename, "utf-8").replace(/\s+$/, ""); - const { code, map, css, cssMap } = svelte.compile(input, { + const { js, css } = svelte.compile(input, { filename, outputFilename: `${outputFilename}.js`, cssOutputFilename: `${outputFilename}.css`, cascade: config.cascade }); - const _code = code.replace(/Svelte v\d+\.\d+\.\d+/, match => match.replace(/\d/g, 'x')); + const _code = js.code.replace(/Svelte v\d+\.\d+\.\d+/, match => match.replace(/\d/g, 'x')); fs.writeFileSync( `${outputFilename}.js`, @@ -42,34 +42,34 @@ describe("sourcemaps", () => { ); fs.writeFileSync( `${outputFilename}.js.map`, - JSON.stringify(map, null, " ") + JSON.stringify(js.map, null, " ") ); if (css.code) { fs.writeFileSync( `${outputFilename}.css`, - `${css}\n/*# sourceMappingURL=output.css.map */` + `${css.code}\n/*# sourceMappingURL=output.css.map */` ); fs.writeFileSync( `${outputFilename}.css.map`, - JSON.stringify(cssMap, null, " ") + JSON.stringify(css.map, null, " ") ); } - assert.deepEqual(map.sources, ["input.html"]); - if (cssMap) assert.deepEqual(cssMap.sources, ["input.html"]); + assert.deepEqual(js.map.sources, ["input.html"]); + if (css.map) assert.deepEqual(css.map.sources, ["input.html"]); const { test } = require(`./samples/${dir}/test.js`); const locateInSource = getLocator(input); - const smc = new SourceMapConsumer(map); + const smc = new SourceMapConsumer(js.map); const locateInGenerated = getLocator(_code); - const smcCss = cssMap && new SourceMapConsumer(cssMap); + const smcCss = css.map && new SourceMapConsumer(css.map); const locateInGeneratedCss = getLocator(css.code || ''); - test({ assert, code: _code, map, smc, smcCss, locateInSource, locateInGenerated, locateInGeneratedCss }); + test({ assert, code: _code, map: js.map, smc, smcCss, locateInSource, locateInGenerated, locateInGeneratedCss }); }); }); }); From 80e0dceb9afd6f7c910b8b667b7d21c50635507b Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 19:57:12 -0400 Subject: [PATCH 10/40] remove validate and Stylesheet from public API --- src/Stats.ts | 13 ++++++++++++- src/index.ts | 24 +++++++++++------------- src/interfaces.ts | 2 +- src/validate/index.ts | 18 ++++++++++-------- test/validator/index.js | 12 ++++++++---- 5 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/Stats.ts b/src/Stats.ts index 873ae15b460e..c1a4b9b64281 100644 --- a/src/Stats.ts +++ b/src/Stats.ts @@ -26,6 +26,8 @@ function collapseTimings(timings) { } export default class Stats { + onwarn: (warning: Warning) => void; + startTime: number; currentTiming: Timing; currentChildren: Timing[]; @@ -33,11 +35,15 @@ export default class Stats { stack: Timing[]; warnings: Warning[]; - constructor() { + constructor({ onwarn }: { + onwarn: (warning: Warning) => void + }) { this.startTime = now(); this.stack = []; this.currentChildren = this.timings = []; + this.onwarn = onwarn; + this.warnings = []; } @@ -99,4 +105,9 @@ export default class Stats { hooks }; } + + warn(warning) { + this.warnings.push(warning); + this.onwarn(warning); + } } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index d13d568069df..1b297e3d298b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -106,11 +106,13 @@ export async function preprocess(source: string, options: PreprocessOptions) { }; } -export function compile(source: string, _options: CompileOptions) { +function compile(source: string, _options: CompileOptions) { const options = normalizeOptions(_options); let parsed: Parsed; - const stats = new Stats(); + const stats = new Stats({ + onwarn: options.onwarn + }); try { stats.start('parse'); @@ -126,23 +128,19 @@ export function compile(source: string, _options: CompileOptions) { stats.stop('stylesheet'); stats.start('validate'); - // TODO remove this when we remove svelte.validate from public API — we - // can use the stats object instead - const onwarn = options.onwarn; - options.onwarn = warning => { - stats.warnings.push(warning); - onwarn(warning); - }; - - validate(parsed, source, stylesheet, options); + validate(parsed, source, stylesheet, stats, options); stats.stop('validate'); + if (options.generate === false) { + return { ast: parsed, stats, js: null, css: null }; + } + const compiler = options.generate === 'ssr' ? generateSSR : generate; return compiler(parsed, source, stylesheet, options, stats); }; -export function create(source: string, _options: CompileOptions = {}) { +function create(source: string, _options: CompileOptions = {}) { _options.format = 'eval'; const compiled = compile(source, _options); @@ -163,4 +161,4 @@ export function create(source: string, _options: CompileOptions = {}) { } } -export { parse, validate, Stylesheet, version as VERSION }; +export { parse, create, compile, version as VERSION }; diff --git a/src/interfaces.ts b/src/interfaces.ts index dfce819d5e1b..8a16b57b5432 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -44,7 +44,7 @@ export interface CompileOptions { format?: ModuleFormat; name?: string; filename?: string; - generate?: string; + generate?: string | false; globals?: ((id: string) => string) | object; amd?: { id?: string; diff --git a/src/validate/index.ts b/src/validate/index.ts index f5bb2d30ef7b..3bdbbc231b3a 100644 --- a/src/validate/index.ts +++ b/src/validate/index.ts @@ -5,15 +5,16 @@ import getCodeFrame from '../utils/getCodeFrame'; import Stats from '../Stats'; import error from '../utils/error'; import Stylesheet from '../css/Stylesheet'; +import Stats from '../Stats'; import { Node, Parsed, CompileOptions, Warning } from '../interfaces'; export class Validator { readonly source: string; readonly filename: string; readonly v2: boolean; + readonly stats: Stats; options: CompileOptions; - onwarn: ({}) => void; locator?: (pos: number) => Location; namespace: string; @@ -34,10 +35,11 @@ export class Validator { actions: Set; }; - constructor(parsed: Parsed, source: string, options: CompileOptions) { + constructor(parsed: Parsed, source: string, stats: Stats, options: CompileOptions) { this.source = source; + this.stats = stats; + this.filename = options.filename; - this.onwarn = options.onwarn; this.options = options; this.v2 = options.parser === 'v2'; @@ -79,7 +81,7 @@ export class Validator { const frame = getCodeFrame(this.source, start.line, start.column); - this.onwarn({ + this.stats.warn({ code, message, frame, @@ -96,9 +98,10 @@ export default function validate( parsed: Parsed, source: string, stylesheet: Stylesheet, + stats: Stats, options: CompileOptions ) { - const { onwarn, onerror, name, filename, store, dev, parser } = options; + const { onerror, name, filename, store, dev, parser } = options; try { if (name && !/^[a-zA-Z_$][a-zA-Z_$0-9]*$/.test(name)) { @@ -108,7 +111,7 @@ export default function validate( if (name && /^[a-z]/.test(name)) { const message = `options.name should be capitalised`; - onwarn({ + stats.warn({ code: `options-lowercase-name`, message, filename, @@ -116,8 +119,7 @@ export default function validate( }); } - const validator = new Validator(parsed, source, { - onwarn, + const validator = new Validator(parsed, source, stats, { name, filename, store, diff --git a/test/validator/index.js b/test/validator/index.js index 211c763f4892..16e84e63aa05 100644 --- a/test/validator/index.js +++ b/test/validator/index.js @@ -28,7 +28,8 @@ describe("validate", () => { const { code, message, pos, loc, end } = warning; warnings.push({ code, message, pos, loc, end }); }, - dev: config.dev + dev: config.dev, + generate: false }); assert.equal(stats.warnings.length, warnings.length); @@ -87,7 +88,8 @@ describe("validate", () => { it("errors if options.name is illegal", () => { assert.throws(() => { svelte.compile("
", { - name: "not.valid" + name: "not.valid", + generate: false }); }, /options\.name must be a valid identifier/); }); @@ -103,7 +105,8 @@ describe("validate", () => { pos: warning.pos, loc: warning.loc }); - } + }, + generate: false }); assert.deepEqual(warnings, [ { @@ -126,7 +129,8 @@ describe("validate", () => { pos: warning.pos, loc: warning.loc }); - } + }, + generate: false }); assert.deepEqual(warnings, []); }); From 4fe8d95a6d4963be3512c75ebbe52f5fe6b095e0 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 20:07:08 -0400 Subject: [PATCH 11/40] dont typecast numeric attributes --- src/generators/nodes/shared/mungeAttribute.ts | 2 +- src/generators/server-side-rendering/visitors/Component.ts | 2 +- test/helpers.js | 4 ++-- test/runtime/samples/component-data-static/main.html | 2 +- .../samples/component-data-static/_actual.html | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/generators/nodes/shared/mungeAttribute.ts b/src/generators/nodes/shared/mungeAttribute.ts index 1cf85de9b781..9609f58d4b4a 100644 --- a/src/generators/nodes/shared/mungeAttribute.ts +++ b/src/generators/nodes/shared/mungeAttribute.ts @@ -55,7 +55,7 @@ export default function mungeAttribute(attribute: Node, block: Block): MungedAtt return { spread: false, name: attribute.name, - value: isNaN(value.data) ? stringify(value.data) : value.data, + value: stringify(value.data), dynamic: false, dependencies: [] }; diff --git a/src/generators/server-side-rendering/visitors/Component.ts b/src/generators/server-side-rendering/visitors/Component.ts index 9c7d7ce930a1..e7325261e3c1 100644 --- a/src/generators/server-side-rendering/visitors/Component.ts +++ b/src/generators/server-side-rendering/visitors/Component.ts @@ -57,7 +57,7 @@ export default function visitComponent( if (attribute.value.length === 1) { const chunk = attribute.value[0]; if (chunk.type === 'Text') { - return isNaN(chunk.data) ? stringify(chunk.data) : chunk.data; + return stringify(chunk.data); } block.contextualise(chunk.expression); diff --git a/test/helpers.js b/test/helpers.js index 767c4a113211..ee065d367520 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -190,7 +190,7 @@ export function showOutput(cwd, options = {}, compile = svelte.compile) { .replace(/^\d/, '_$&') .replace(/[^a-zA-Z0-9_$]/g, ''); - const { code } = compile( + const { js } = compile( fs.readFileSync(`${cwd}/${file}`, 'utf-8'), Object.assign(options, { filename: file, @@ -200,7 +200,7 @@ export function showOutput(cwd, options = {}, compile = svelte.compile) { ); console.log( // eslint-disable-line no-console - `\n>> ${chalk.cyan.bold(file)}\n${addLineNumbers(code)}\n<< ${chalk.cyan.bold(file)}` + `\n>> ${chalk.cyan.bold(file)}\n${addLineNumbers(js.code)}\n<< ${chalk.cyan.bold(file)}` ); }); } diff --git a/test/runtime/samples/component-data-static/main.html b/test/runtime/samples/component-data-static/main.html index 0df72c1465b9..6b62cad8fd93 100644 --- a/test/runtime/samples/component-data-static/main.html +++ b/test/runtime/samples/component-data-static/main.html @@ -1,5 +1,5 @@
- +
\ No newline at end of file diff --git a/test/parser/samples/dynamic-import/output-v2.json b/test/parser/samples/dynamic-import/output-v2.json deleted file mode 100644 index b27a780a58e4..000000000000 --- a/test/parser/samples/dynamic-import/output-v2.json +++ /dev/null @@ -1,182 +0,0 @@ -{ - "hash": 1867472549, - "html": { - "start": null, - "end": null, - "type": "Fragment", - "children": [] - }, - "css": null, - "js": { - "start": 0, - "end": 131, - "attributes": [], - "content": { - "type": "Program", - "start": 8, - "end": 122, - "body": [ - { - "type": "ExportDefaultDeclaration", - "start": 10, - "end": 121, - "declaration": { - "type": "ObjectExpression", - "start": 25, - "end": 121, - "properties": [ - { - "type": "Property", - "start": 29, - "end": 118, - "method": true, - "shorthand": false, - "computed": false, - "key": { - "type": "Identifier", - "start": 29, - "end": 37, - "name": "oncreate" - }, - "kind": "init", - "value": { - "type": "FunctionExpression", - "start": 37, - "end": 118, - "id": null, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 40, - "end": 118, - "body": [ - { - "type": "ExpressionStatement", - "start": 45, - "end": 114, - "expression": { - "type": "CallExpression", - "start": 45, - "end": 113, - "callee": { - "type": "MemberExpression", - "start": 45, - "end": 68, - "object": { - "type": "CallExpression", - "start": 45, - "end": 63, - "callee": { - "type": "Import", - "start": 45, - "end": 51 - }, - "arguments": [ - { - "type": "Literal", - "start": 52, - "end": 62, - "value": "./foo.js", - "raw": "'./foo.js'" - } - ] - }, - "property": { - "type": "Identifier", - "start": 64, - "end": 68, - "name": "then" - }, - "computed": false - }, - "arguments": [ - { - "type": "ArrowFunctionExpression", - "start": 69, - "end": 112, - "id": null, - "generator": false, - "expression": false, - "async": false, - "params": [ - { - "type": "Identifier", - "start": 69, - "end": 72, - "name": "foo" - } - ], - "body": { - "type": "BlockStatement", - "start": 76, - "end": 112, - "body": [ - { - "type": "ExpressionStatement", - "start": 82, - "end": 107, - "expression": { - "type": "CallExpression", - "start": 82, - "end": 106, - "callee": { - "type": "MemberExpression", - "start": 82, - "end": 93, - "object": { - "type": "Identifier", - "start": 82, - "end": 89, - "name": "console" - }, - "property": { - "type": "Identifier", - "start": 90, - "end": 93, - "name": "log" - }, - "computed": false - }, - "arguments": [ - { - "type": "MemberExpression", - "start": 94, - "end": 105, - "object": { - "type": "Identifier", - "start": 94, - "end": 97, - "name": "foo" - }, - "property": { - "type": "Identifier", - "start": 98, - "end": 105, - "name": "default" - }, - "computed": false - } - ] - } - } - ] - } - } - ] - } - } - ] - } - } - } - ] - } - } - ], - "sourceType": "module" - } - } -} \ No newline at end of file diff --git a/test/parser/samples/each-block-destructured/input-v2.html b/test/parser/samples/each-block-destructured/input-v2.html deleted file mode 100644 index 4ddf33ef8585..000000000000 --- a/test/parser/samples/each-block-destructured/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#each animals as [key, value]} -

{key}: {value}

-{/each} diff --git a/test/parser/samples/each-block-destructured/input.html b/test/parser/samples/each-block-destructured/input.html index 7209f5503d8a..4ddf33ef8585 100644 --- a/test/parser/samples/each-block-destructured/input.html +++ b/test/parser/samples/each-block-destructured/input.html @@ -1,3 +1,3 @@ -{{#each animals as [key, value]}} -

{{key}}: {{value}}

-{{/each}} +{#each animals as [key, value]} +

{key}: {value}

+{/each} diff --git a/test/parser/samples/each-block-destructured/output-v2.json b/test/parser/samples/each-block-destructured/output-v2.json deleted file mode 100644 index 38d5ddc770ec..000000000000 --- a/test/parser/samples/each-block-destructured/output-v2.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "hash": "gtdm5e", - "html": { - "start": 0, - "end": 62, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 62, - "type": "EachBlock", - "expression": { - "type": "Identifier", - "start": 7, - "end": 14, - "name": "animals" - }, - "children": [ - { - "start": 33, - "end": 54, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 36, - "end": 41, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 37, - "end": 40, - "name": "key" - } - }, - { - "start": 41, - "end": 43, - "type": "Text", - "data": ": " - }, - { - "start": 43, - "end": 50, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 44, - "end": 49, - "name": "value" - } - } - ] - } - ], - "destructuredContexts": [ - "key", - "value" - ], - "context": "key_value" - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/each-block-destructured/output.json b/test/parser/samples/each-block-destructured/output.json index 897fec88b82a..38d5ddc770ec 100644 --- a/test/parser/samples/each-block-destructured/output.json +++ b/test/parser/samples/each-block-destructured/output.json @@ -1,53 +1,53 @@ { - "hash": 2621498076, + "hash": "gtdm5e", "html": { "start": 0, - "end": 70, + "end": 62, "type": "Fragment", "children": [ { "start": 0, - "end": 70, + "end": 62, "type": "EachBlock", "expression": { "type": "Identifier", - "start": 8, - "end": 15, + "start": 7, + "end": 14, "name": "animals" }, "children": [ { - "start": 35, - "end": 60, + "start": 33, + "end": 54, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 38, - "end": 45, + "start": 36, + "end": 41, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 40, - "end": 43, + "start": 37, + "end": 40, "name": "key" } }, { - "start": 45, - "end": 47, + "start": 41, + "end": 43, "type": "Text", "data": ": " }, { - "start": 47, - "end": 56, + "start": 43, + "end": 50, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 49, - "end": 54, + "start": 44, + "end": 49, "name": "value" } } diff --git a/test/parser/samples/each-block-else/input-v2.html b/test/parser/samples/each-block-else/input-v2.html deleted file mode 100644 index dc96d8b946be..000000000000 --- a/test/parser/samples/each-block-else/input-v2.html +++ /dev/null @@ -1,5 +0,0 @@ -{#each animals as animal} -

{animal}

-{:else} -

no animals

-{/each} diff --git a/test/parser/samples/each-block-else/input.html b/test/parser/samples/each-block-else/input.html index 59925e8db7e1..dc96d8b946be 100644 --- a/test/parser/samples/each-block-else/input.html +++ b/test/parser/samples/each-block-else/input.html @@ -1,5 +1,5 @@ -{{#each animals as animal}} -

{{animal}}

-{{else}} +{#each animals as animal} +

{animal}

+{:else}

no animals

-{{/each}} +{/each} diff --git a/test/parser/samples/each-block-else/output-v2.json b/test/parser/samples/each-block-else/output-v2.json deleted file mode 100644 index 9f8c5da79ba8..000000000000 --- a/test/parser/samples/each-block-else/output-v2.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "hash": "ljl07n", - "html": { - "start": 0, - "end": 77, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 77, - "type": "EachBlock", - "expression": { - "type": "Identifier", - "start": 7, - "end": 14, - "name": "animals" - }, - "children": [ - { - "start": 27, - "end": 42, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 30, - "end": 38, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 31, - "end": 37, - "name": "animal" - } - } - ] - } - ], - "context": "animal", - "else": { - "start": 50, - "end": 70, - "type": "ElseBlock", - "children": [ - { - "start": 52, - "end": 69, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 55, - "end": 65, - "type": "Text", - "data": "no animals" - } - ] - } - ] - } - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/each-block-else/output.json b/test/parser/samples/each-block-else/output.json index 0dadad5f650f..9f8c5da79ba8 100644 --- a/test/parser/samples/each-block-else/output.json +++ b/test/parser/samples/each-block-else/output.json @@ -1,36 +1,36 @@ { - "hash": 3238289871, + "hash": "ljl07n", "html": { "start": 0, - "end": 84, + "end": 77, "type": "Fragment", "children": [ { "start": 0, - "end": 84, + "end": 77, "type": "EachBlock", "expression": { "type": "Identifier", - "start": 8, - "end": 15, + "start": 7, + "end": 14, "name": "animals" }, "children": [ { - "start": 29, - "end": 46, + "start": 27, + "end": 42, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 32, - "end": 42, + "start": 30, + "end": 38, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 34, - "end": 40, + "start": 31, + "end": 37, "name": "animal" } } @@ -39,20 +39,20 @@ ], "context": "animal", "else": { - "start": 55, - "end": 75, + "start": 50, + "end": 70, "type": "ElseBlock", "children": [ { - "start": 57, - "end": 74, + "start": 52, + "end": 69, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 60, - "end": 70, + "start": 55, + "end": 65, "type": "Text", "data": "no animals" } diff --git a/test/parser/samples/each-block-indexed/input-v2.html b/test/parser/samples/each-block-indexed/input-v2.html deleted file mode 100644 index d5602ec82c06..000000000000 --- a/test/parser/samples/each-block-indexed/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#each animals as animal, i} -

{i}: {animal}

-{/each} diff --git a/test/parser/samples/each-block-indexed/input.html b/test/parser/samples/each-block-indexed/input.html index 5c1c74da6613..d5602ec82c06 100644 --- a/test/parser/samples/each-block-indexed/input.html +++ b/test/parser/samples/each-block-indexed/input.html @@ -1,3 +1,3 @@ -{{#each animals as animal, i}} -

{{i}}: {{animal}}

-{{/each}} +{#each animals as animal, i} +

{i}: {animal}

+{/each} diff --git a/test/parser/samples/each-block-indexed/output-v2.json b/test/parser/samples/each-block-indexed/output-v2.json deleted file mode 100644 index 9ffa02aaa871..000000000000 --- a/test/parser/samples/each-block-indexed/output-v2.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "hash": "1143n2g", - "html": { - "start": 0, - "end": 58, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 58, - "type": "EachBlock", - "expression": { - "type": "Identifier", - "start": 7, - "end": 14, - "name": "animals" - }, - "children": [ - { - "start": 30, - "end": 50, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 33, - "end": 36, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 34, - "end": 35, - "name": "i" - } - }, - { - "start": 36, - "end": 38, - "type": "Text", - "data": ": " - }, - { - "start": 38, - "end": 46, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 39, - "end": 45, - "name": "animal" - } - } - ] - } - ], - "context": "animal", - "index": "i" - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/each-block-indexed/output.json b/test/parser/samples/each-block-indexed/output.json index fc8954d6ad96..9ffa02aaa871 100644 --- a/test/parser/samples/each-block-indexed/output.json +++ b/test/parser/samples/each-block-indexed/output.json @@ -1,53 +1,53 @@ { - "hash": 2841674990, + "hash": "1143n2g", "html": { "start": 0, - "end": 66, + "end": 58, "type": "Fragment", "children": [ { "start": 0, - "end": 66, + "end": 58, "type": "EachBlock", "expression": { "type": "Identifier", - "start": 8, - "end": 15, + "start": 7, + "end": 14, "name": "animals" }, "children": [ { - "start": 32, - "end": 56, + "start": 30, + "end": 50, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 35, - "end": 40, + "start": 33, + "end": 36, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 37, - "end": 38, + "start": 34, + "end": 35, "name": "i" } }, { - "start": 40, - "end": 42, + "start": 36, + "end": 38, "type": "Text", "data": ": " }, { - "start": 42, - "end": 52, + "start": 38, + "end": 46, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 44, - "end": 50, + "start": 39, + "end": 45, "name": "animal" } } diff --git a/test/parser/samples/each-block-keyed/input-v2.html b/test/parser/samples/each-block-keyed/input-v2.html deleted file mode 100644 index 46348678d448..000000000000 --- a/test/parser/samples/each-block-keyed/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#each todos as todo (todo.id)} -

{todo}

-{/each} diff --git a/test/parser/samples/each-block-keyed/input.html b/test/parser/samples/each-block-keyed/input.html index 2bc79c9c8b47..46348678d448 100644 --- a/test/parser/samples/each-block-keyed/input.html +++ b/test/parser/samples/each-block-keyed/input.html @@ -1,3 +1,3 @@ -{{#each todos as todo @id}} -

{{todo}}

-{{/each}} +{#each todos as todo (todo.id)} +

{todo}

+{/each} diff --git a/test/parser/samples/each-block-keyed/output-v2.json b/test/parser/samples/each-block-keyed/output-v2.json deleted file mode 100644 index 461992347b74..000000000000 --- a/test/parser/samples/each-block-keyed/output-v2.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "hash": "1x6az5m", - "html": { - "start": 0, - "end": 54, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 54, - "type": "EachBlock", - "expression": { - "type": "Identifier", - "start": 7, - "end": 12, - "name": "todos" - }, - "children": [ - { - "start": 33, - "end": 46, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 36, - "end": 42, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 37, - "end": 41, - "name": "todo" - } - } - ] - } - ], - "context": "todo", - "key": "id" - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/each-block-keyed/output.json b/test/parser/samples/each-block-keyed/output.json index 1a16afb82b31..461992347b74 100644 --- a/test/parser/samples/each-block-keyed/output.json +++ b/test/parser/samples/each-block-keyed/output.json @@ -1,5 +1,5 @@ { - "hash": 2025411181, + "hash": "1x6az5m", "html": { "start": 0, "end": 54, @@ -11,26 +11,26 @@ "type": "EachBlock", "expression": { "type": "Identifier", - "start": 8, - "end": 13, + "start": 7, + "end": 12, "name": "todos" }, "children": [ { - "start": 29, - "end": 44, + "start": 33, + "end": 46, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 32, - "end": 40, + "start": 36, + "end": 42, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 34, - "end": 38, + "start": 37, + "end": 41, "name": "todo" } } diff --git a/test/parser/samples/each-block/input-v2.html b/test/parser/samples/each-block/input-v2.html deleted file mode 100644 index 83a5e88ddd2a..000000000000 --- a/test/parser/samples/each-block/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#each animals as animal} -

{animal}

-{/each} diff --git a/test/parser/samples/each-block/input.html b/test/parser/samples/each-block/input.html index 23bfc3c46565..83a5e88ddd2a 100644 --- a/test/parser/samples/each-block/input.html +++ b/test/parser/samples/each-block/input.html @@ -1,3 +1,3 @@ -{{#each animals as animal}} -

{{animal}}

-{{/each}} +{#each animals as animal} +

{animal}

+{/each} diff --git a/test/parser/samples/each-block/output-v2.json b/test/parser/samples/each-block/output-v2.json deleted file mode 100644 index 7df4a20eba77..000000000000 --- a/test/parser/samples/each-block/output-v2.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "hash": "mzeq0s", - "html": { - "start": 0, - "end": 50, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 50, - "type": "EachBlock", - "expression": { - "type": "Identifier", - "start": 7, - "end": 14, - "name": "animals" - }, - "children": [ - { - "start": 27, - "end": 42, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 30, - "end": 38, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 31, - "end": 37, - "name": "animal" - } - } - ] - } - ], - "context": "animal" - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/each-block/output.json b/test/parser/samples/each-block/output.json index e549faca3953..7df4a20eba77 100644 --- a/test/parser/samples/each-block/output.json +++ b/test/parser/samples/each-block/output.json @@ -1,36 +1,36 @@ { - "hash": 220340986, + "hash": "mzeq0s", "html": { "start": 0, - "end": 56, + "end": 50, "type": "Fragment", "children": [ { "start": 0, - "end": 56, + "end": 50, "type": "EachBlock", "expression": { "type": "Identifier", - "start": 8, - "end": 15, + "start": 7, + "end": 14, "name": "animals" }, "children": [ { - "start": 29, - "end": 46, + "start": 27, + "end": 42, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 32, - "end": 42, + "start": 30, + "end": 38, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 34, - "end": 40, + "start": 31, + "end": 37, "name": "animal" } } diff --git a/test/parser/samples/element-with-mustache/input-v2.html b/test/parser/samples/element-with-mustache/input-v2.html deleted file mode 100644 index 1e9232da02fd..000000000000 --- a/test/parser/samples/element-with-mustache/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -

hello {name}!

diff --git a/test/parser/samples/element-with-mustache/input.html b/test/parser/samples/element-with-mustache/input.html index 6a2a43bf7984..1e9232da02fd 100644 --- a/test/parser/samples/element-with-mustache/input.html +++ b/test/parser/samples/element-with-mustache/input.html @@ -1 +1 @@ -

hello {{name}}!

+

hello {name}!

diff --git a/test/parser/samples/element-with-mustache/output-v2.json b/test/parser/samples/element-with-mustache/output-v2.json deleted file mode 100644 index 76e71dc3278f..000000000000 --- a/test/parser/samples/element-with-mustache/output-v2.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "hash": 1265376132, - "html": { - "start": 0, - "end": 22, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 22, - "type": "Element", - "name": "h1", - "attributes": [], - "children": [ - { - "start": 4, - "end": 10, - "type": "Text", - "data": "hello " - }, - { - "start": 10, - "end": 16, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 11, - "end": 15, - "name": "name" - } - }, - { - "start": 16, - "end": 17, - "type": "Text", - "data": "!" - } - ] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/element-with-mustache/output.json b/test/parser/samples/element-with-mustache/output.json index fd6799e1922f..76e71dc3278f 100644 --- a/test/parser/samples/element-with-mustache/output.json +++ b/test/parser/samples/element-with-mustache/output.json @@ -2,12 +2,12 @@ "hash": 1265376132, "html": { "start": 0, - "end": 24, + "end": 22, "type": "Fragment", "children": [ { "start": 0, - "end": 24, + "end": 22, "type": "Element", "name": "h1", "attributes": [], @@ -20,18 +20,18 @@ }, { "start": 10, - "end": 18, + "end": 16, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 12, - "end": 16, + "start": 11, + "end": 15, "name": "name" } }, { - "start": 18, - "end": 19, + "start": 16, + "end": 17, "type": "Text", "data": "!" } diff --git a/test/parser/samples/element-with-text/input-v2.html b/test/parser/samples/element-with-text/input-v2.html deleted file mode 100644 index fcf3199655df..000000000000 --- a/test/parser/samples/element-with-text/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file diff --git a/test/parser/samples/element-with-text/input.html b/test/parser/samples/element-with-text/input.html index 61dba8bc46f0..fcf3199655df 100644 --- a/test/parser/samples/element-with-text/input.html +++ b/test/parser/samples/element-with-text/input.html @@ -1 +1 @@ -test +test \ No newline at end of file diff --git a/test/parser/samples/element-with-text/output-v2.json b/test/parser/samples/element-with-text/output-v2.json deleted file mode 100644 index 22cae35547ca..000000000000 --- a/test/parser/samples/element-with-text/output-v2.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "hash": 611274658, - "html": { - "start": 0, - "end": 17, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 17, - "type": "Element", - "name": "span", - "attributes": [], - "children": [ - { - "start": 6, - "end": 10, - "type": "Text", - "data": "test" - } - ] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/elements/input-v2.html b/test/parser/samples/elements/input-v2.html deleted file mode 100644 index 937d25b42e2e..000000000000 --- a/test/parser/samples/elements/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/elements/input.html b/test/parser/samples/elements/input.html index c50eddd41fab..937d25b42e2e 100644 --- a/test/parser/samples/elements/input.html +++ b/test/parser/samples/elements/input.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/test/parser/samples/elements/output-v2.json b/test/parser/samples/elements/output-v2.json deleted file mode 100644 index 7b4e6bffe12e..000000000000 --- a/test/parser/samples/elements/output-v2.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "hash": 825536165, - "html": { - "start": 0, - "end": 15, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 15, - "type": "Element", - "name": "!doctype", - "attributes": [ - { - "start": 10, - "end": 14, - "type": "Attribute", - "name": "html", - "value": true - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/error-binding-disabled/error-v2.json b/test/parser/samples/error-binding-disabled/error-v2.json deleted file mode 100644 index 71953c41766f..000000000000 --- a/test/parser/samples/error-binding-disabled/error-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "code": "binding-disabled", - "message": "Two-way binding is disabled", - "loc": { - "line": 1, - "column": 7 - }, - "pos": 7 -} \ No newline at end of file diff --git a/test/parser/samples/error-binding-disabled/input-v2.html b/test/parser/samples/error-binding-disabled/input-v2.html deleted file mode 100644 index 3af20a9ced1b..000000000000 --- a/test/parser/samples/error-binding-disabled/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/error-binding-disabled/input.html b/test/parser/samples/error-binding-disabled/input.html index 6a7bf8566cbb..3af20a9ced1b 100644 --- a/test/parser/samples/error-binding-disabled/input.html +++ b/test/parser/samples/error-binding-disabled/input.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/test/parser/samples/error-binding-mustaches/error-v2.json b/test/parser/samples/error-binding-mustaches/error-v2.json deleted file mode 100644 index 4d239270860f..000000000000 --- a/test/parser/samples/error-binding-mustaches/error-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "code": "invalid-directive-value", - "message": "directive values should not be wrapped — use 'foo', not '{foo}'", - "loc": { - "line": 1, - "column": 19 - }, - "pos": 19 -} \ No newline at end of file diff --git a/test/parser/samples/error-binding-mustaches/error.json b/test/parser/samples/error-binding-mustaches/error.json index 0c4f9e01bd40..4d239270860f 100644 --- a/test/parser/samples/error-binding-mustaches/error.json +++ b/test/parser/samples/error-binding-mustaches/error.json @@ -1,6 +1,6 @@ { "code": "invalid-directive-value", - "message": "directive values should not be wrapped — use 'foo', not '{{foo}}'", + "message": "directive values should not be wrapped — use 'foo', not '{foo}'", "loc": { "line": 1, "column": 19 diff --git a/test/parser/samples/error-binding-mustaches/input-v2.html b/test/parser/samples/error-binding-mustaches/input-v2.html deleted file mode 100644 index 2629696c9ec8..000000000000 --- a/test/parser/samples/error-binding-mustaches/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/parser/samples/error-binding-mustaches/input.html b/test/parser/samples/error-binding-mustaches/input.html index a334ea705578..2629696c9ec8 100644 --- a/test/parser/samples/error-binding-mustaches/input.html +++ b/test/parser/samples/error-binding-mustaches/input.html @@ -1 +1 @@ - + diff --git a/test/parser/samples/error-binding-rvalue/error-v2.json b/test/parser/samples/error-binding-rvalue/error-v2.json deleted file mode 100644 index b774b8a29f3c..000000000000 --- a/test/parser/samples/error-binding-rvalue/error-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "code": "invalid-directive-value", - "message": "Can only bind to an identifier (e.g. `foo`) or a member expression (e.g. `foo.bar` or `foo[baz]`)", - "pos": 19, - "loc": { - "line": 1, - "column": 19 - } -} \ No newline at end of file diff --git a/test/parser/samples/error-binding-rvalue/input-v2.html b/test/parser/samples/error-binding-rvalue/input-v2.html deleted file mode 100644 index 0b1f716c237e..000000000000 --- a/test/parser/samples/error-binding-rvalue/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/error-comment-unclosed/error-v2.json b/test/parser/samples/error-comment-unclosed/error-v2.json deleted file mode 100644 index d83ecbdc0961..000000000000 --- a/test/parser/samples/error-comment-unclosed/error-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "code": "unexpected-eof", - "message": "comment was left open, expected -->", - "loc": { - "line": 1, - "column": 24 - }, - "pos": 24 -} diff --git a/test/parser/samples/error-comment-unclosed/input-v2.html b/test/parser/samples/error-comment-unclosed/input-v2.html deleted file mode 100644 index fe6d748e1b04..000000000000 --- a/test/parser/samples/error-comment-unclosed/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - - - - -

{foo}

- - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/js/samples/collapses-text-around-comments/input.html b/test/js/samples/collapses-text-around-comments/input.html index a6c1ae40f7fb..54c15b792200 100644 --- a/test/js/samples/collapses-text-around-comments/input.html +++ b/test/js/samples/collapses-text-around-comments/input.html @@ -3,7 +3,7 @@ -

{{foo}}

+

{foo}

diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 5347ce59a13c..8cd4bf0011db 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -122,11 +122,11 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function a(x) { +function a({ x }) { return x * 2; } -function b(x) { +function b({ x }) { return x * 3; } @@ -162,8 +162,8 @@ assign(SvelteComponent.prototype, proto); SvelteComponent.prototype._recompute = function _recompute(changed, state) { if (changed.x) { - if (this._differs(state.a, (state.a = a(state.x)))) changed.a = true; - if (this._differs(state.b, (state.b = b(state.x)))) changed.b = true; + if (this._differs(state.a, (state.a = a(state)))) changed.a = true; + if (this._differs(state.b, (state.b = b(state)))) changed.b = true; } }; diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index 2398f4bdee14..f1228ca0b698 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -1,11 +1,11 @@ /* generated by Svelte vX.Y.Z */ import { assign, init, noop, proto } from "svelte/shared.js"; -function a(x) { +function a({ x }) { return x * 2; } -function b(x) { +function b({ x }) { return x * 3; } @@ -41,8 +41,8 @@ assign(SvelteComponent.prototype, proto); SvelteComponent.prototype._recompute = function _recompute(changed, state) { if (changed.x) { - if (this._differs(state.a, (state.a = a(state.x)))) changed.a = true; - if (this._differs(state.b, (state.b = b(state.x)))) changed.b = true; + 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; \ No newline at end of file diff --git a/test/js/samples/computed-collapsed-if/input.html b/test/js/samples/computed-collapsed-if/input.html index a68513b860fe..c7280e5ef8bb 100644 --- a/test/js/samples/computed-collapsed-if/input.html +++ b/test/js/samples/computed-collapsed-if/input.html @@ -1,8 +1,8 @@ \ No newline at end of file diff --git a/test/js/samples/deconflict-builtins/_actual-bundle-v2.js b/test/js/samples/deconflict-builtins/_actual-bundle-v2.js deleted file mode 100644 index 2f9dd2db1d49..000000000000 --- a/test/js/samples/deconflict-builtins/_actual-bundle-v2.js +++ /dev/null @@ -1,276 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function destroyEach(iterations) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(); - } -} - -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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var each_anchor; - - var each_value = state.createElement; - - var each_blocks = []; - - for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, assign(assign({}, state), { - each_value: each_value, - node: each_value[i], - node_index: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - each_anchor = createComment(); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(each_anchor, target, anchor); - }, - - p: function update(changed, state) { - var each_value = state.createElement; - - if (changed.createElement) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - node: each_value[i], - node_index: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(each_anchor.parentNode, each_anchor); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(each_anchor); - }, - - d: function destroy$$1() { - destroyEach(each_blocks); - } - }; -} - -// (1:0) {#each createElement as node} -function create_each_block(component, state) { - var node = state.node, each_value = state.each_value, node_index = state.node_index; - var span, text_value = node, text; - - return { - c: function create() { - span = createElement("span"); - text = createText(text_value); - }, - - m: function mount(target, anchor) { - insertNode(span, target, anchor); - appendNode(text, span); - }, - - p: function update(changed, state) { - node = state.node; - each_value = state.each_value; - node_index = state.node_index; - if ((changed.createElement) && text_value !== (text_value = node)) { - text.data = text_value; - } - }, - - u: function unmount() { - detachNode(span); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-builtins/expected-bundle-v2.js b/test/js/samples/deconflict-builtins/expected-bundle-v2.js deleted file mode 100644 index 2f9dd2db1d49..000000000000 --- a/test/js/samples/deconflict-builtins/expected-bundle-v2.js +++ /dev/null @@ -1,276 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function destroyEach(iterations) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(); - } -} - -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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var each_anchor; - - var each_value = state.createElement; - - var each_blocks = []; - - for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, assign(assign({}, state), { - each_value: each_value, - node: each_value[i], - node_index: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - each_anchor = createComment(); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(each_anchor, target, anchor); - }, - - p: function update(changed, state) { - var each_value = state.createElement; - - if (changed.createElement) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - node: each_value[i], - node_index: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(each_anchor.parentNode, each_anchor); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(each_anchor); - }, - - d: function destroy$$1() { - destroyEach(each_blocks); - } - }; -} - -// (1:0) {#each createElement as node} -function create_each_block(component, state) { - var node = state.node, each_value = state.each_value, node_index = state.node_index; - var span, text_value = node, text; - - return { - c: function create() { - span = createElement("span"); - text = createText(text_value); - }, - - m: function mount(target, anchor) { - insertNode(span, target, anchor); - appendNode(text, span); - }, - - p: function update(changed, state) { - node = state.node; - each_value = state.each_value; - node_index = state.node_index; - if ((changed.createElement) && text_value !== (text_value = node)) { - text.data = text_value; - } - }, - - u: function unmount() { - detachNode(span); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js index 0bfddd1f0dee..2f9dd2db1d49 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ b/test/js/samples/deconflict-builtins/expected-bundle.js @@ -226,7 +226,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#each createElement as node}} +// (1:0) {#each createElement as node} function create_each_block(component, state) { var node = state.node, each_value = state.each_value, node_index = state.node_index; var span, text_value = node, text; diff --git a/test/js/samples/deconflict-builtins/expected-v2.js b/test/js/samples/deconflict-builtins/expected-v2.js deleted file mode 100644 index f6861d255714..000000000000 --- a/test/js/samples/deconflict-builtins/expected-v2.js +++ /dev/null @@ -1,124 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createComment, createElement, createText, destroyEach, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var each_anchor; - - var each_value = state.createElement; - - var each_blocks = []; - - for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, assign(assign({}, state), { - each_value: each_value, - node: each_value[i], - node_index: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - each_anchor = createComment(); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(each_anchor, target, anchor); - }, - - p: function update(changed, state) { - var each_value = state.createElement; - - if (changed.createElement) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - node: each_value[i], - node_index: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(each_anchor.parentNode, each_anchor); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(each_anchor); - }, - - d: function destroy() { - destroyEach(each_blocks); - } - }; -} - -// (1:0) {#each createElement as node} -function create_each_block(component, state) { - var node = state.node, each_value = state.each_value, node_index = state.node_index; - var span, text_value = node, text; - - return { - c: function create() { - span = createElement("span"); - text = createText(text_value); - }, - - m: function mount(target, anchor) { - insertNode(span, target, anchor); - appendNode(text, span); - }, - - p: function update(changed, state) { - node = state.node; - each_value = state.each_value; - node_index = state.node_index; - if ((changed.createElement) && text_value !== (text_value = node)) { - text.data = text_value; - } - }, - - u: function unmount() { - detachNode(span); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/deconflict-builtins/expected.js b/test/js/samples/deconflict-builtins/expected.js index e81e05fd32a6..f6861d255714 100644 --- a/test/js/samples/deconflict-builtins/expected.js +++ b/test/js/samples/deconflict-builtins/expected.js @@ -75,7 +75,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#each createElement as node}} +// (1:0) {#each createElement as node} function create_each_block(component, state) { var node = state.node, each_value = state.each_value, node_index = state.node_index; var span, text_value = node, text; diff --git a/test/js/samples/deconflict-builtins/input-v2.html b/test/js/samples/deconflict-builtins/input-v2.html deleted file mode 100644 index 48a413b32353..000000000000 --- a/test/js/samples/deconflict-builtins/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#each createElement as node} - {node} -{/each} \ No newline at end of file diff --git a/test/js/samples/deconflict-builtins/input.html b/test/js/samples/deconflict-builtins/input.html index a6556d00c557..48a413b32353 100644 --- a/test/js/samples/deconflict-builtins/input.html +++ b/test/js/samples/deconflict-builtins/input.html @@ -1,3 +1,3 @@ -{{#each createElement as node}} - {{node}} -{{/each}} \ No newline at end of file +{#each createElement as node} + {node} +{/each} \ No newline at end of file diff --git a/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js b/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js deleted file mode 100644 index e0ff6a11717d..000000000000 --- a/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js +++ /dev/null @@ -1,232 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 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); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var protoDev = { - destroy: destroyDev, - get, - fire, - on, - set: setDev, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function bar({ foo }) { - return foo * 2; -} - -function create_main_fragment(component, state) { - var p, text_value = state.Math.max(0, state.foo), text, text_1, text_2; - - return { - c: function create() { - p = createElement("p"); - text = createText(text_value); - text_1 = createText("\n\t"); - text_2 = createText(state.bar); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - appendNode(text_2, p); - }, - - p: function update(changed, state) { - if ((changed.Math || changed.foo) && text_value !== (text_value = state.Math.max(0, state.foo))) { - text.data = text_value; - } - - if (changed.bar) { - text_2.data = state.bar; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -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._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/dev-warning-missing-data-computed/expected-bundle-v2.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js deleted file mode 100644 index e0ff6a11717d..000000000000 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js +++ /dev/null @@ -1,232 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 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); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var protoDev = { - destroy: destroyDev, - get, - fire, - on, - set: setDev, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function bar({ foo }) { - return foo * 2; -} - -function create_main_fragment(component, state) { - var p, text_value = state.Math.max(0, state.foo), text, text_1, text_2; - - return { - c: function create() { - p = createElement("p"); - text = createText(text_value); - text_1 = createText("\n\t"); - text_2 = createText(state.bar); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - appendNode(text_2, p); - }, - - p: function update(changed, state) { - if ((changed.Math || changed.foo) && text_value !== (text_value = state.Math.max(0, state.foo))) { - text.data = text_value; - } - - if (changed.bar) { - text_2.data = state.bar; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -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._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/dev-warning-missing-data-computed/expected-bundle.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js index effef47cb9a1..e0ff6a11717d 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js @@ -160,7 +160,7 @@ var protoDev = { /* generated by Svelte vX.Y.Z */ -function bar(foo) { +function bar({ foo }) { return foo * 2; } @@ -225,7 +225,7 @@ SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) { SvelteComponent.prototype._recompute = function _recompute(changed, state) { if (changed.foo) { - if (this._differs(state.bar, (state.bar = bar(state.foo)))) changed.bar = true; + if (this._differs(state.bar, (state.bar = bar(state)))) changed.bar = true; } }; diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-v2.js b/test/js/samples/dev-warning-missing-data-computed/expected-v2.js deleted file mode 100644 index 52dee37250c4..000000000000 --- a/test/js/samples/dev-warning-missing-data-computed/expected-v2.js +++ /dev/null @@ -1,72 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, createText, detachNode, init, insertNode, noop, protoDev } from "svelte/shared.js"; - -function bar({ foo }) { - return foo * 2; -} - -function create_main_fragment(component, state) { - var p, text_value = state.Math.max(0, state.foo), text, text_1, text_2; - - return { - c: function create() { - p = createElement("p"); - text = createText(text_value); - text_1 = createText("\n\t"); - text_2 = createText(state.bar); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - appendNode(text_2, p); - }, - - p: function update(changed, state) { - if ((changed.Math || changed.foo) && text_value !== (text_value = state.Math.max(0, state.foo))) { - text.data = text_value; - } - - if (changed.bar) { - text_2.data = state.bar; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -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._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; \ No newline at end of file diff --git a/test/js/samples/dev-warning-missing-data-computed/expected.js b/test/js/samples/dev-warning-missing-data-computed/expected.js index edf4331457b6..52dee37250c4 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { appendNode, assign, createElement, createText, detachNode, init, insertNode, noop, protoDev } from "svelte/shared.js"; -function bar(foo) { +function bar({ foo }) { return foo * 2; } @@ -66,7 +66,7 @@ SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) { SvelteComponent.prototype._recompute = function _recompute(changed, state) { if (changed.foo) { - if (this._differs(state.bar, (state.bar = bar(state.foo)))) changed.bar = true; + if (this._differs(state.bar, (state.bar = bar(state)))) changed.bar = true; } } export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/dev-warning-missing-data-computed/input-v2.html b/test/js/samples/dev-warning-missing-data-computed/input-v2.html deleted file mode 100644 index 06eb210493b0..000000000000 --- a/test/js/samples/dev-warning-missing-data-computed/input-v2.html +++ /dev/null @@ -1,12 +0,0 @@ -

- {Math.max(0, foo)} - {bar} -

- - \ No newline at end of file diff --git a/test/js/samples/dev-warning-missing-data-computed/input.html b/test/js/samples/dev-warning-missing-data-computed/input.html index f497b6e82491..06eb210493b0 100644 --- a/test/js/samples/dev-warning-missing-data-computed/input.html +++ b/test/js/samples/dev-warning-missing-data-computed/input.html @@ -1,12 +1,12 @@

- {{Math.max(0, foo)}} - {{bar}} + {Math.max(0, foo)} + {bar}

\ No newline at end of file diff --git a/test/js/samples/do-use-dataset/_actual-bundle-v2.js b/test/js/samples/do-use-dataset/_actual-bundle-v2.js deleted file mode 100644 index 32af7494c3df..000000000000 --- a/test/js/samples/do-use-dataset/_actual-bundle-v2.js +++ /dev/null @@ -1,193 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.dataset.foo = "bar"; - div_1.dataset.foo = state.bar; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - div_1.dataset.foo = state.bar; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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/do-use-dataset/expected-bundle-v2.js b/test/js/samples/do-use-dataset/expected-bundle-v2.js deleted file mode 100644 index 32af7494c3df..000000000000 --- a/test/js/samples/do-use-dataset/expected-bundle-v2.js +++ /dev/null @@ -1,193 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.dataset.foo = "bar"; - div_1.dataset.foo = state.bar; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - div_1.dataset.foo = state.bar; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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/do-use-dataset/expected-v2.js b/test/js/samples/do-use-dataset/expected-v2.js deleted file mode 100644 index b88636a606d5..000000000000 --- a/test/js/samples/do-use-dataset/expected-v2.js +++ /dev/null @@ -1,55 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.dataset.foo = "bar"; - div_1.dataset.foo = state.bar; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - div_1.dataset.foo = state.bar; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/do-use-dataset/input-v2.html b/test/js/samples/do-use-dataset/input-v2.html deleted file mode 100644 index fcd821731e49..000000000000 --- a/test/js/samples/do-use-dataset/input-v2.html +++ /dev/null @@ -1,2 +0,0 @@ -
-
diff --git a/test/js/samples/do-use-dataset/input.html b/test/js/samples/do-use-dataset/input.html index acd9d623b44b..fcd821731e49 100644 --- a/test/js/samples/do-use-dataset/input.html +++ b/test/js/samples/do-use-dataset/input.html @@ -1,2 +1,2 @@
-
+
diff --git a/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js b/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js deleted file mode 100644 index 5e9def191391..000000000000 --- a/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.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 insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setAttribute(div, "data-foo", "bar"); - setAttribute(div_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(div_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js deleted file mode 100644 index 5e9def191391..000000000000 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.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 insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setAttribute(div, "data-foo", "bar"); - setAttribute(div_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(div_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/dont-use-dataset-in-legacy/expected-v2.js deleted file mode 100644 index 699da1270b87..000000000000 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-v2.js +++ /dev/null @@ -1,55 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, createElement, createText, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setAttribute(div, "data-foo", "bar"); - setAttribute(div_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(div_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/dont-use-dataset-in-legacy/input-v2.html b/test/js/samples/dont-use-dataset-in-legacy/input-v2.html deleted file mode 100644 index fcd821731e49..000000000000 --- a/test/js/samples/dont-use-dataset-in-legacy/input-v2.html +++ /dev/null @@ -1,2 +0,0 @@ -
-
diff --git a/test/js/samples/dont-use-dataset-in-legacy/input.html b/test/js/samples/dont-use-dataset-in-legacy/input.html index acd9d623b44b..fcd821731e49 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/input.html +++ b/test/js/samples/dont-use-dataset-in-legacy/input.html @@ -1,2 +1,2 @@
-
+
diff --git a/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js b/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js deleted file mode 100644 index 54b8382a2db9..000000000000 --- a/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js +++ /dev/null @@ -1,195 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var svg, g, g_1; - - return { - c: function create() { - svg = createSvgElement("svg"); - g = createSvgElement("g"); - g_1 = createSvgElement("g"); - this.h(); - }, - - h: function hydrate() { - setAttribute(g, "data-foo", "bar"); - setAttribute(g_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(svg, target, anchor); - appendNode(g, svg); - appendNode(g_1, svg); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(g_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(svg); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js deleted file mode 100644 index 54b8382a2db9..000000000000 --- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js +++ /dev/null @@ -1,195 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var svg, g, g_1; - - return { - c: function create() { - svg = createSvgElement("svg"); - g = createSvgElement("g"); - g_1 = createSvgElement("g"); - this.h(); - }, - - h: function hydrate() { - setAttribute(g, "data-foo", "bar"); - setAttribute(g_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(svg, target, anchor); - appendNode(g, svg); - appendNode(g_1, svg); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(g_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(svg); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/dont-use-dataset-in-svg/expected-v2.js deleted file mode 100644 index 42693672549b..000000000000 --- a/test/js/samples/dont-use-dataset-in-svg/expected-v2.js +++ /dev/null @@ -1,53 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createSvgElement, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var svg, g, g_1; - - return { - c: function create() { - svg = createSvgElement("svg"); - g = createSvgElement("g"); - g_1 = createSvgElement("g"); - this.h(); - }, - - h: function hydrate() { - setAttribute(g, "data-foo", "bar"); - setAttribute(g_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(svg, target, anchor); - appendNode(g, svg); - appendNode(g_1, svg); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(g_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(svg); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/dont-use-dataset-in-svg/input-v2.html b/test/js/samples/dont-use-dataset-in-svg/input-v2.html deleted file mode 100644 index 3032322b8010..000000000000 --- a/test/js/samples/dont-use-dataset-in-svg/input-v2.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/test/js/samples/dont-use-dataset-in-svg/input.html b/test/js/samples/dont-use-dataset-in-svg/input.html index c351e2dc18e4..3032322b8010 100644 --- a/test/js/samples/dont-use-dataset-in-svg/input.html +++ b/test/js/samples/dont-use-dataset-in-svg/input.html @@ -1,4 +1,4 @@ - + diff --git a/test/js/samples/each-block-changed-check/_actual-bundle-v2.js b/test/js/samples/each-block-changed-check/_actual-bundle-v2.js deleted file mode 100644 index 89c3cab24320..000000000000 --- a/test/js/samples/each-block-changed-check/_actual-bundle-v2.js +++ /dev/null @@ -1,323 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, 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) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(); - } -} - -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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var text, p, text_1; - - var each_value = state.comments; - - var each_blocks = []; - - for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, assign(assign({}, state), { - each_value: each_value, - comment: each_value[i], - i: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - text = createText("\n\n"); - p = createElement("p"); - text_1 = createText(state.foo); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(text, target, anchor); - insertNode(p, target, anchor); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - var each_value = state.comments; - - if (changed.comments || changed.elapsed || changed.time) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - comment: each_value[i], - i: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(text.parentNode, text); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - - if (changed.foo) { - text_1.data = state.foo; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(text); - detachNode(p); - }, - - d: function destroy$$1() { - destroyEach(each_blocks); - } - }; -} - -// (1:0) {#each comments as comment, i} -function create_each_block(component, state) { - var comment = state.comment, each_value = state.each_value, i = state.i; - var div, strong, text, text_1, span, text_2_value = comment.author, text_2, text_3, text_4_value = state.elapsed(comment.time, state.time), text_4, text_5, text_6, raw_value = comment.html, raw_before; - - return { - c: function create() { - div = createElement("div"); - strong = createElement("strong"); - text = createText(i); - text_1 = createText("\n\n\t\t"); - span = createElement("span"); - text_2 = createText(text_2_value); - text_3 = createText(" wrote "); - text_4 = createText(text_4_value); - text_5 = createText(" ago:"); - text_6 = createText("\n\n\t\t"); - raw_before = createElement('noscript'); - this.h(); - }, - - h: function hydrate() { - span.className = "meta"; - div.className = "comment"; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - appendNode(strong, div); - appendNode(text, strong); - appendNode(text_1, div); - appendNode(span, div); - appendNode(text_2, span); - appendNode(text_3, span); - appendNode(text_4, span); - appendNode(text_5, span); - appendNode(text_6, div); - appendNode(raw_before, div); - raw_before.insertAdjacentHTML("afterend", raw_value); - }, - - p: function update(changed, state) { - comment = state.comment; - each_value = state.each_value; - i = state.i; - if ((changed.comments) && text_2_value !== (text_2_value = comment.author)) { - text_2.data = text_2_value; - } - - if ((changed.elapsed || changed.comments || changed.time) && text_4_value !== (text_4_value = state.elapsed(comment.time, state.time))) { - text_4.data = text_4_value; - } - - if ((changed.comments) && raw_value !== (raw_value = comment.html)) { - detachAfter(raw_before); - raw_before.insertAdjacentHTML("afterend", raw_value); - } - }, - - u: function unmount() { - detachAfter(raw_before); - - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-changed-check/expected-bundle-v2.js b/test/js/samples/each-block-changed-check/expected-bundle-v2.js deleted file mode 100644 index 89c3cab24320..000000000000 --- a/test/js/samples/each-block-changed-check/expected-bundle-v2.js +++ /dev/null @@ -1,323 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, 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) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(); - } -} - -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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var text, p, text_1; - - var each_value = state.comments; - - var each_blocks = []; - - for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, assign(assign({}, state), { - each_value: each_value, - comment: each_value[i], - i: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - text = createText("\n\n"); - p = createElement("p"); - text_1 = createText(state.foo); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(text, target, anchor); - insertNode(p, target, anchor); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - var each_value = state.comments; - - if (changed.comments || changed.elapsed || changed.time) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - comment: each_value[i], - i: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(text.parentNode, text); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - - if (changed.foo) { - text_1.data = state.foo; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(text); - detachNode(p); - }, - - d: function destroy$$1() { - destroyEach(each_blocks); - } - }; -} - -// (1:0) {#each comments as comment, i} -function create_each_block(component, state) { - var comment = state.comment, each_value = state.each_value, i = state.i; - var div, strong, text, text_1, span, text_2_value = comment.author, text_2, text_3, text_4_value = state.elapsed(comment.time, state.time), text_4, text_5, text_6, raw_value = comment.html, raw_before; - - return { - c: function create() { - div = createElement("div"); - strong = createElement("strong"); - text = createText(i); - text_1 = createText("\n\n\t\t"); - span = createElement("span"); - text_2 = createText(text_2_value); - text_3 = createText(" wrote "); - text_4 = createText(text_4_value); - text_5 = createText(" ago:"); - text_6 = createText("\n\n\t\t"); - raw_before = createElement('noscript'); - this.h(); - }, - - h: function hydrate() { - span.className = "meta"; - div.className = "comment"; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - appendNode(strong, div); - appendNode(text, strong); - appendNode(text_1, div); - appendNode(span, div); - appendNode(text_2, span); - appendNode(text_3, span); - appendNode(text_4, span); - appendNode(text_5, span); - appendNode(text_6, div); - appendNode(raw_before, div); - raw_before.insertAdjacentHTML("afterend", raw_value); - }, - - p: function update(changed, state) { - comment = state.comment; - each_value = state.each_value; - i = state.i; - if ((changed.comments) && text_2_value !== (text_2_value = comment.author)) { - text_2.data = text_2_value; - } - - if ((changed.elapsed || changed.comments || changed.time) && text_4_value !== (text_4_value = state.elapsed(comment.time, state.time))) { - text_4.data = text_4_value; - } - - if ((changed.comments) && raw_value !== (raw_value = comment.html)) { - detachAfter(raw_before); - raw_before.insertAdjacentHTML("afterend", raw_value); - } - }, - - u: function unmount() { - detachAfter(raw_before); - - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js index 846fea0ba702..89c3cab24320 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -237,7 +237,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#each comments as comment, i}} +// (1:0) {#each comments as comment, i} function create_each_block(component, state) { var comment = state.comment, each_value = state.each_value, i = state.i; var div, strong, text, text_1, span, text_2_value = comment.author, text_2, text_3, text_4_value = state.elapsed(comment.time, state.time), text_4, text_5, text_6, raw_value = comment.html, raw_before; diff --git a/test/js/samples/each-block-changed-check/expected-v2.js b/test/js/samples/each-block-changed-check/expected-v2.js deleted file mode 100644 index e7e0ccca306f..000000000000 --- a/test/js/samples/each-block-changed-check/expected-v2.js +++ /dev/null @@ -1,169 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, createText, destroyEach, detachAfter, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var text, p, text_1; - - var each_value = state.comments; - - var each_blocks = []; - - for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, assign(assign({}, state), { - each_value: each_value, - comment: each_value[i], - i: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - text = createText("\n\n"); - p = createElement("p"); - text_1 = createText(state.foo); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(text, target, anchor); - insertNode(p, target, anchor); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - var each_value = state.comments; - - if (changed.comments || changed.elapsed || changed.time) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - comment: each_value[i], - i: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(text.parentNode, text); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - - if (changed.foo) { - text_1.data = state.foo; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(text); - detachNode(p); - }, - - d: function destroy() { - destroyEach(each_blocks); - } - }; -} - -// (1:0) {#each comments as comment, i} -function create_each_block(component, state) { - var comment = state.comment, each_value = state.each_value, i = state.i; - var div, strong, text, text_1, span, text_2_value = comment.author, text_2, text_3, text_4_value = state.elapsed(comment.time, state.time), text_4, text_5, text_6, raw_value = comment.html, raw_before; - - return { - c: function create() { - div = createElement("div"); - strong = createElement("strong"); - text = createText(i); - text_1 = createText("\n\n\t\t"); - span = createElement("span"); - text_2 = createText(text_2_value); - text_3 = createText(" wrote "); - text_4 = createText(text_4_value); - text_5 = createText(" ago:"); - text_6 = createText("\n\n\t\t"); - raw_before = createElement('noscript'); - this.h(); - }, - - h: function hydrate() { - span.className = "meta"; - div.className = "comment"; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - appendNode(strong, div); - appendNode(text, strong); - appendNode(text_1, div); - appendNode(span, div); - appendNode(text_2, span); - appendNode(text_3, span); - appendNode(text_4, span); - appendNode(text_5, span); - appendNode(text_6, div); - appendNode(raw_before, div); - raw_before.insertAdjacentHTML("afterend", raw_value); - }, - - p: function update(changed, state) { - comment = state.comment; - each_value = state.each_value; - i = state.i; - if ((changed.comments) && text_2_value !== (text_2_value = comment.author)) { - text_2.data = text_2_value; - } - - if ((changed.elapsed || changed.comments || changed.time) && text_4_value !== (text_4_value = state.elapsed(comment.time, state.time))) { - text_4.data = text_4_value; - } - - if ((changed.comments) && raw_value !== (raw_value = comment.html)) { - detachAfter(raw_before); - raw_before.insertAdjacentHTML("afterend", raw_value); - } - }, - - u: function unmount() { - detachAfter(raw_before); - - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index cefd0a133859..e7e0ccca306f 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -84,7 +84,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#each comments as comment, i}} +// (1:0) {#each comments as comment, i} function create_each_block(component, state) { var comment = state.comment, each_value = state.each_value, i = state.i; var div, strong, text, text_1, span, text_2_value = comment.author, text_2, text_3, text_4_value = state.elapsed(comment.time, state.time), text_4, text_5, text_6, raw_value = comment.html, raw_before; diff --git a/test/js/samples/each-block-changed-check/input-v2.html b/test/js/samples/each-block-changed-check/input-v2.html deleted file mode 100644 index b5b5703857c4..000000000000 --- a/test/js/samples/each-block-changed-check/input-v2.html +++ /dev/null @@ -1,13 +0,0 @@ -{#each comments as comment, i} -
- {i} - - - {comment.author} wrote {elapsed(comment.time, time)} ago: - - - {@html comment.html} -
-{/each} - -

{foo}

\ No newline at end of file diff --git a/test/js/samples/each-block-changed-check/input.html b/test/js/samples/each-block-changed-check/input.html index 5a80a1a6c17c..b5b5703857c4 100644 --- a/test/js/samples/each-block-changed-check/input.html +++ b/test/js/samples/each-block-changed-check/input.html @@ -1,13 +1,13 @@ -{{#each comments as comment, i}} +{#each comments as comment, i}
- {{i}} + {i} - {{comment.author}} wrote {{elapsed(comment.time, time)}} ago: + {comment.author} wrote {elapsed(comment.time, time)} ago: - {{{comment.html}}} + {@html comment.html}
-{{/each}} +{/each} -

{{foo}}

\ No newline at end of file +

{foo}

\ No newline at end of file diff --git a/test/js/samples/head-no-whitespace/_actual-bundle-v2.js b/test/js/samples/head-no-whitespace/_actual-bundle-v2.js deleted file mode 100644 index 7f88574b70f6..000000000000 --- a/test/js/samples/head-no-whitespace/_actual-bundle-v2.js +++ /dev/null @@ -1,184 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var meta, meta_1; - - return { - c: function create() { - meta = createElement("meta"); - meta_1 = createElement("meta"); - this.h(); - }, - - h: function hydrate() { - meta.name = "twitter:creator"; - meta.content = "@sveltejs"; - meta_1.name = "twitter:title"; - meta_1.content = "Svelte"; - }, - - m: function mount(target, anchor) { - appendNode(meta, document.head); - appendNode(meta_1, document.head); - }, - - p: noop, - - u: function unmount() { - detachNode(meta); - detachNode(meta_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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/head-no-whitespace/expected-bundle-v2.js b/test/js/samples/head-no-whitespace/expected-bundle-v2.js deleted file mode 100644 index 7f88574b70f6..000000000000 --- a/test/js/samples/head-no-whitespace/expected-bundle-v2.js +++ /dev/null @@ -1,184 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var meta, meta_1; - - return { - c: function create() { - meta = createElement("meta"); - meta_1 = createElement("meta"); - this.h(); - }, - - h: function hydrate() { - meta.name = "twitter:creator"; - meta.content = "@sveltejs"; - meta_1.name = "twitter:title"; - meta_1.content = "Svelte"; - }, - - m: function mount(target, anchor) { - appendNode(meta, document.head); - appendNode(meta_1, document.head); - }, - - p: noop, - - u: function unmount() { - detachNode(meta); - detachNode(meta_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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/head-no-whitespace/expected-v2.js b/test/js/samples/head-no-whitespace/expected-v2.js deleted file mode 100644 index 9818f4211658..000000000000 --- a/test/js/samples/head-no-whitespace/expected-v2.js +++ /dev/null @@ -1,50 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, detachNode, init, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var meta, meta_1; - - return { - c: function create() { - meta = createElement("meta"); - meta_1 = createElement("meta"); - this.h(); - }, - - h: function hydrate() { - meta.name = "twitter:creator"; - meta.content = "@sveltejs"; - meta_1.name = "twitter:title"; - meta_1.content = "Svelte"; - }, - - m: function mount(target, anchor) { - appendNode(meta, document.head); - appendNode(meta_1, document.head); - }, - - p: noop, - - u: function unmount() { - detachNode(meta); - detachNode(meta_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/head-no-whitespace/input-v2.html b/test/js/samples/head-no-whitespace/input-v2.html deleted file mode 100644 index 000b643abeb6..000000000000 --- a/test/js/samples/head-no-whitespace/input-v2.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/test/js/samples/head-no-whitespace/input.html b/test/js/samples/head-no-whitespace/input.html index 37c387083d39..000b643abeb6 100644 --- a/test/js/samples/head-no-whitespace/input.html +++ b/test/js/samples/head-no-whitespace/input.html @@ -1,4 +1,4 @@ -<:Head> + - \ No newline at end of file + \ No newline at end of file diff --git a/test/js/samples/if-block-no-update/_actual-bundle-v2.js b/test/js/samples/if-block-no-update/_actual-bundle-v2.js deleted file mode 100644 index 1760a2ca607f..000000000000 --- a/test/js/samples/if-block-no-update/_actual-bundle-v2.js +++ /dev/null @@ -1,242 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var if_block_anchor; - - function select_block_type(state) { - if (state.foo) return create_if_block; - return create_if_block_1; - } - - var current_block_type = select_block_type(state); - var if_block = current_block_type(component, state); - - return { - c: function create() { - if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (current_block_type !== (current_block_type = select_block_type(state))) { - if_block.u(); - if_block.d(); - if_block = current_block_type(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - }, - - u: function unmount() { - if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy$$1() { - if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (3:0) {:else} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "not foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/if-block-no-update/expected-bundle-v2.js deleted file mode 100644 index 1760a2ca607f..000000000000 --- a/test/js/samples/if-block-no-update/expected-bundle-v2.js +++ /dev/null @@ -1,242 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var if_block_anchor; - - function select_block_type(state) { - if (state.foo) return create_if_block; - return create_if_block_1; - } - - var current_block_type = select_block_type(state); - var if_block = current_block_type(component, state); - - return { - c: function create() { - if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (current_block_type !== (current_block_type = select_block_type(state))) { - if_block.u(); - if_block.d(); - if_block = current_block_type(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - }, - - u: function unmount() { - if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy$$1() { - if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (3:0) {:else} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "not foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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 index 303bd8482128..1760a2ca607f 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -181,7 +181,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#if foo}} +// (1:0) {#if foo} function create_if_block(component, state) { var p; @@ -203,7 +203,7 @@ function create_if_block(component, state) { }; } -// (3:0) {{else}} +// (3:0) {:else} function create_if_block_1(component, state) { var p; diff --git a/test/js/samples/if-block-no-update/expected-v2.js b/test/js/samples/if-block-no-update/expected-v2.js deleted file mode 100644 index c06ff6ee679a..000000000000 --- a/test/js/samples/if-block-no-update/expected-v2.js +++ /dev/null @@ -1,104 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, createComment, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var if_block_anchor; - - function select_block_type(state) { - if (state.foo) return create_if_block; - return create_if_block_1; - } - - var current_block_type = select_block_type(state); - var if_block = current_block_type(component, state); - - return { - c: function create() { - if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (current_block_type !== (current_block_type = select_block_type(state))) { - if_block.u(); - if_block.d(); - if_block = current_block_type(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - }, - - u: function unmount() { - if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy() { - if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (3:0) {:else} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "not foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index af8b381ba422..c06ff6ee679a 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -44,7 +44,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#if foo}} +// (1:0) {#if foo} function create_if_block(component, state) { var p; @@ -66,7 +66,7 @@ function create_if_block(component, state) { }; } -// (3:0) {{else}} +// (3:0) {:else} function create_if_block_1(component, state) { var p; diff --git a/test/js/samples/if-block-no-update/input-v2.html b/test/js/samples/if-block-no-update/input-v2.html deleted file mode 100644 index 57de21915969..000000000000 --- a/test/js/samples/if-block-no-update/input-v2.html +++ /dev/null @@ -1,5 +0,0 @@ -{#if foo} -

foo!

-{:else} -

not foo!

-{/if} \ No newline at end of file diff --git a/test/js/samples/if-block-no-update/input.html b/test/js/samples/if-block-no-update/input.html index c73bfc624277..57de21915969 100644 --- a/test/js/samples/if-block-no-update/input.html +++ b/test/js/samples/if-block-no-update/input.html @@ -1,5 +1,5 @@ -{{#if foo}} +{#if foo}

foo!

-{{else}} +{:else}

not foo!

-{{/if}} \ No newline at end of file +{/if} \ No newline at end of file diff --git a/test/js/samples/if-block-simple/_actual-bundle-v2.js b/test/js/samples/if-block-simple/_actual-bundle-v2.js deleted file mode 100644 index f71aafff9415..000000000000 --- a/test/js/samples/if-block-simple/_actual-bundle-v2.js +++ /dev/null @@ -1,218 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var if_block_anchor; - - var if_block = (state.foo) && create_if_block(component, state); - - return { - c: function create() { - if (if_block) if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if (if_block) if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.foo) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - }, - - u: function unmount() { - if (if_block) if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy$$1() { - if (if_block) if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/if-block-simple/expected-bundle-v2.js deleted file mode 100644 index f71aafff9415..000000000000 --- a/test/js/samples/if-block-simple/expected-bundle-v2.js +++ /dev/null @@ -1,218 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var if_block_anchor; - - var if_block = (state.foo) && create_if_block(component, state); - - return { - c: function create() { - if (if_block) if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if (if_block) if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.foo) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - }, - - u: function unmount() { - if (if_block) if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy$$1() { - if (if_block) if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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 index 7fe3bd33d7f8..f71aafff9415 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -179,7 +179,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#if foo}} +// (1:0) {#if foo} function create_if_block(component, state) { var p; diff --git a/test/js/samples/if-block-simple/expected-v2.js b/test/js/samples/if-block-simple/expected-v2.js deleted file mode 100644 index b3447471d31e..000000000000 --- a/test/js/samples/if-block-simple/expected-v2.js +++ /dev/null @@ -1,80 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, createComment, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var if_block_anchor; - - var if_block = (state.foo) && create_if_block(component, state); - - return { - c: function create() { - if (if_block) if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if (if_block) if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.foo) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - }, - - u: function unmount() { - if (if_block) if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy() { - if (if_block) if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index 11d3ccbdc645..b3447471d31e 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -42,7 +42,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#if foo}} +// (1:0) {#if foo} function create_if_block(component, state) { var p; diff --git a/test/js/samples/if-block-simple/input-v2.html b/test/js/samples/if-block-simple/input-v2.html deleted file mode 100644 index e36517e10c2d..000000000000 --- a/test/js/samples/if-block-simple/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#if foo} -

foo!

-{/if} \ No newline at end of file diff --git a/test/js/samples/if-block-simple/input.html b/test/js/samples/if-block-simple/input.html index 050095b913a8..e36517e10c2d 100644 --- a/test/js/samples/if-block-simple/input.html +++ b/test/js/samples/if-block-simple/input.html @@ -1,3 +1,3 @@ -{{#if foo}} +{#if foo}

foo!

-{{/if}} \ No newline at end of file +{/if} \ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js deleted file mode 100644 index bd3bacfac27a..000000000000 --- a/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js +++ /dev/null @@ -1,191 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - - if (changed.x || changed.y) { - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js deleted file mode 100644 index bd3bacfac27a..000000000000 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js +++ /dev/null @@ -1,191 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - - if (changed.x || changed.y) { - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/inline-style-optimized-multiple/expected-v2.js deleted file mode 100644 index 7a94993b690c..000000000000 --- a/test/js/samples/inline-style-optimized-multiple/expected-v2.js +++ /dev/null @@ -1,53 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - - if (changed.x || changed.y) { - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-multiple/input-v2.html b/test/js/samples/inline-style-optimized-multiple/input-v2.html deleted file mode 100644 index d9448e0ab06d..000000000000 --- a/test/js/samples/inline-style-optimized-multiple/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-multiple/input.html b/test/js/samples/inline-style-optimized-multiple/input.html index 92d9cb805d72..d9448e0ab06d 100644 --- a/test/js/samples/inline-style-optimized-multiple/input.html +++ b/test/js/samples/inline-style-optimized-multiple/input.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js deleted file mode 100644 index 411990568209..000000000000 --- a/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.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 insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.data) { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js deleted file mode 100644 index 411990568209..000000000000 --- a/test/js/samples/inline-style-optimized-url/expected-bundle-v2.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 insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.data) { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/inline-style-optimized-url/expected-v2.js deleted file mode 100644 index 5a27ecfa4948..000000000000 --- a/test/js/samples/inline-style-optimized-url/expected-v2.js +++ /dev/null @@ -1,48 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.data) { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-url/input-v2.html b/test/js/samples/inline-style-optimized-url/input-v2.html deleted file mode 100644 index 677da52c30f4..000000000000 --- a/test/js/samples/inline-style-optimized-url/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-url/input.html b/test/js/samples/inline-style-optimized-url/input.html index 7e3b2928eb23..677da52c30f4 100644 --- a/test/js/samples/inline-style-optimized-url/input.html +++ b/test/js/samples/inline-style-optimized-url/input.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/test/js/samples/inline-style-optimized/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized/_actual-bundle-v2.js deleted file mode 100644 index 7643ee066d12..000000000000 --- a/test/js/samples/inline-style-optimized/_actual-bundle-v2.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 insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/inline-style-optimized/expected-bundle-v2.js deleted file mode 100644 index 7643ee066d12..000000000000 --- a/test/js/samples/inline-style-optimized/expected-bundle-v2.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 insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/inline-style-optimized/expected-v2.js deleted file mode 100644 index 86dabe8d21e1..000000000000 --- a/test/js/samples/inline-style-optimized/expected-v2.js +++ /dev/null @@ -1,48 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/inline-style-optimized/input-v2.html b/test/js/samples/inline-style-optimized/input-v2.html deleted file mode 100644 index 004fd595c94f..000000000000 --- a/test/js/samples/inline-style-optimized/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/js/samples/inline-style-optimized/input.html b/test/js/samples/inline-style-optimized/input.html index ff7d95fb6efa..004fd595c94f 100644 --- a/test/js/samples/inline-style-optimized/input.html +++ b/test/js/samples/inline-style-optimized/input.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js b/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js deleted file mode 100644 index 67b27347432a..000000000000 --- a/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.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 insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1, div_1_style_value; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.style.cssText = state.style; - div_1.style.cssText = div_1_style_value = "" + state.key + ": " + state.value; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.style) { - div.style.cssText = state.style; - } - - if ((changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + state.key + ": " + state.value)) { - div_1.style.cssText = div_1_style_value; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js deleted file mode 100644 index 67b27347432a..000000000000 --- a/test/js/samples/inline-style-unoptimized/expected-bundle-v2.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 insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1, div_1_style_value; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.style.cssText = state.style; - div_1.style.cssText = div_1_style_value = "" + state.key + ": " + state.value; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.style) { - div.style.cssText = state.style; - } - - if ((changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + state.key + ": " + state.value)) { - div_1.style.cssText = div_1_style_value; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/inline-style-unoptimized/expected-v2.js deleted file mode 100644 index 7d7e933c1226..000000000000 --- a/test/js/samples/inline-style-unoptimized/expected-v2.js +++ /dev/null @@ -1,59 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var div, text, div_1, div_1_style_value; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.style.cssText = state.style; - div_1.style.cssText = div_1_style_value = "" + state.key + ": " + state.value; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.style) { - div.style.cssText = state.style; - } - - if ((changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + state.key + ": " + state.value)) { - div_1.style.cssText = div_1_style_value; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/inline-style-unoptimized/input-v2.html b/test/js/samples/inline-style-unoptimized/input-v2.html deleted file mode 100644 index eac76d5b6ede..000000000000 --- a/test/js/samples/inline-style-unoptimized/input-v2.html +++ /dev/null @@ -1,2 +0,0 @@ -
-
\ No newline at end of file diff --git a/test/js/samples/inline-style-unoptimized/input.html b/test/js/samples/inline-style-unoptimized/input.html index 87e4592bfd90..eac76d5b6ede 100644 --- a/test/js/samples/inline-style-unoptimized/input.html +++ b/test/js/samples/inline-style-unoptimized/input.html @@ -1,2 +1,2 @@ -
-
\ No newline at end of file +
+
\ No newline at end of file diff --git a/test/js/samples/title/_actual-bundle-v2.js b/test/js/samples/title/_actual-bundle-v2.js deleted file mode 100644 index 27cae18b3d14..000000000000 --- a/test/js/samples/title/_actual-bundle-v2.js +++ /dev/null @@ -1,161 +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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var title_value; - - document.title = title_value = "a " + state.custom + " title"; - - return { - c: noop, - - m: noop, - - p: function update(changed, state) { - if ((changed.custom) && title_value !== (title_value = "a " + state.custom + " title")) { - document.title = title_value; - } - }, - - u: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/title/expected-bundle-v2.js deleted file mode 100644 index 27cae18b3d14..000000000000 --- a/test/js/samples/title/expected-bundle-v2.js +++ /dev/null @@ -1,161 +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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var title_value; - - document.title = title_value = "a " + state.custom + " title"; - - return { - c: noop, - - m: noop, - - p: function update(changed, state) { - if ((changed.custom) && title_value !== (title_value = "a " + state.custom + " title")) { - document.title = title_value; - } - }, - - u: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/title/expected-v2.js deleted file mode 100644 index 0e059bbb4c67..000000000000 --- a/test/js/samples/title/expected-v2.js +++ /dev/null @@ -1,39 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, init, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var title_value; - - document.title = title_value = "a " + state.custom + " title"; - - return { - c: noop, - - m: noop, - - p: function update(changed, state) { - if ((changed.custom) && title_value !== (title_value = "a " + state.custom + " title")) { - document.title = title_value; - } - }, - - u: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/title/input-v2.html b/test/js/samples/title/input-v2.html deleted file mode 100644 index 0eb2a9519de6..000000000000 --- a/test/js/samples/title/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ - - a {custom} title - \ No newline at end of file diff --git a/test/js/samples/title/input.html b/test/js/samples/title/input.html index b006a8f50f65..0eb2a9519de6 100644 --- a/test/js/samples/title/input.html +++ b/test/js/samples/title/input.html @@ -1,3 +1,3 @@ -<:Head> - a {{custom}} title - \ No newline at end of file + + a {custom} title + \ No newline at end of file diff --git a/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js b/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js deleted file mode 100644 index 1fda063de122..000000000000 --- a/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js +++ /dev/null @@ -1,408 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, p, text_2, text_3, text_4, p_1, text_6, text_8, if_block_4_anchor; - - var if_block = (state.a) && create_if_block(component, state); - - var if_block_1 = (state.b) && create_if_block_1(component, state); - - var if_block_2 = (state.c) && create_if_block_2(component, state); - - var if_block_3 = (state.d) && create_if_block_3(component, state); - - var if_block_4 = (state.e) && create_if_block_4(component, state); - - return { - c: function create() { - div = createElement("div"); - if (if_block) if_block.c(); - text = createText("\n\n\t"); - p = createElement("p"); - p.textContent = "this can be used as an anchor"; - text_2 = createText("\n\n\t"); - if (if_block_1) if_block_1.c(); - text_3 = createText("\n\n\t"); - if (if_block_2) if_block_2.c(); - text_4 = createText("\n\n\t"); - p_1 = createElement("p"); - p_1.textContent = "so can this"; - text_6 = createText("\n\n\t"); - if (if_block_3) if_block_3.c(); - text_8 = createText("\n\n"); - if (if_block_4) if_block_4.c(); - if_block_4_anchor = createComment(); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - if (if_block) if_block.m(div, null); - appendNode(text, div); - appendNode(p, div); - appendNode(text_2, div); - if (if_block_1) if_block_1.m(div, null); - appendNode(text_3, div); - if (if_block_2) if_block_2.m(div, null); - appendNode(text_4, div); - appendNode(p_1, div); - appendNode(text_6, div); - if (if_block_3) if_block_3.m(div, null); - insertNode(text_8, target, anchor); - if (if_block_4) if_block_4.m(target, anchor); - insertNode(if_block_4_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.a) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(div, text); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - - if (state.b) { - if (!if_block_1) { - if_block_1 = create_if_block_1(component, state); - if_block_1.c(); - if_block_1.m(div, text_3); - } - } else if (if_block_1) { - if_block_1.u(); - if_block_1.d(); - if_block_1 = null; - } - - if (state.c) { - if (!if_block_2) { - if_block_2 = create_if_block_2(component, state); - if_block_2.c(); - if_block_2.m(div, text_4); - } - } else if (if_block_2) { - if_block_2.u(); - if_block_2.d(); - if_block_2 = null; - } - - if (state.d) { - if (!if_block_3) { - if_block_3 = create_if_block_3(component, state); - if_block_3.c(); - if_block_3.m(div, null); - } - } else if (if_block_3) { - if_block_3.u(); - if_block_3.d(); - if_block_3 = null; - } - - if (state.e) { - if (!if_block_4) { - if_block_4 = create_if_block_4(component, state); - if_block_4.c(); - if_block_4.m(if_block_4_anchor.parentNode, if_block_4_anchor); - } - } else if (if_block_4) { - if_block_4.u(); - if_block_4.d(); - if_block_4 = null; - } - }, - - u: function unmount() { - detachNode(div); - if (if_block) if_block.u(); - if (if_block_1) if_block_1.u(); - if (if_block_2) if_block_2.u(); - if (if_block_3) if_block_3.u(); - detachNode(text_8); - if (if_block_4) if_block_4.u(); - detachNode(if_block_4_anchor); - }, - - d: function destroy$$1() { - if (if_block) if_block.d(); - if (if_block_1) if_block_1.d(); - if (if_block_2) if_block_2.d(); - if (if_block_3) if_block_3.d(); - if (if_block_4) if_block_4.d(); - } - }; -} - -// (2:1) {#if a} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "a"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (8:1) {#if b} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "b"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (12:1) {#if c} -function create_if_block_2(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "c"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (18:1) {#if d} -function create_if_block_3(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "d"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (25:0) {#if e} -function create_if_block_4(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "e"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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-v2.js b/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js deleted file mode 100644 index 1fda063de122..000000000000 --- a/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js +++ /dev/null @@ -1,408 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, p, text_2, text_3, text_4, p_1, text_6, text_8, if_block_4_anchor; - - var if_block = (state.a) && create_if_block(component, state); - - var if_block_1 = (state.b) && create_if_block_1(component, state); - - var if_block_2 = (state.c) && create_if_block_2(component, state); - - var if_block_3 = (state.d) && create_if_block_3(component, state); - - var if_block_4 = (state.e) && create_if_block_4(component, state); - - return { - c: function create() { - div = createElement("div"); - if (if_block) if_block.c(); - text = createText("\n\n\t"); - p = createElement("p"); - p.textContent = "this can be used as an anchor"; - text_2 = createText("\n\n\t"); - if (if_block_1) if_block_1.c(); - text_3 = createText("\n\n\t"); - if (if_block_2) if_block_2.c(); - text_4 = createText("\n\n\t"); - p_1 = createElement("p"); - p_1.textContent = "so can this"; - text_6 = createText("\n\n\t"); - if (if_block_3) if_block_3.c(); - text_8 = createText("\n\n"); - if (if_block_4) if_block_4.c(); - if_block_4_anchor = createComment(); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - if (if_block) if_block.m(div, null); - appendNode(text, div); - appendNode(p, div); - appendNode(text_2, div); - if (if_block_1) if_block_1.m(div, null); - appendNode(text_3, div); - if (if_block_2) if_block_2.m(div, null); - appendNode(text_4, div); - appendNode(p_1, div); - appendNode(text_6, div); - if (if_block_3) if_block_3.m(div, null); - insertNode(text_8, target, anchor); - if (if_block_4) if_block_4.m(target, anchor); - insertNode(if_block_4_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.a) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(div, text); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - - if (state.b) { - if (!if_block_1) { - if_block_1 = create_if_block_1(component, state); - if_block_1.c(); - if_block_1.m(div, text_3); - } - } else if (if_block_1) { - if_block_1.u(); - if_block_1.d(); - if_block_1 = null; - } - - if (state.c) { - if (!if_block_2) { - if_block_2 = create_if_block_2(component, state); - if_block_2.c(); - if_block_2.m(div, text_4); - } - } else if (if_block_2) { - if_block_2.u(); - if_block_2.d(); - if_block_2 = null; - } - - if (state.d) { - if (!if_block_3) { - if_block_3 = create_if_block_3(component, state); - if_block_3.c(); - if_block_3.m(div, null); - } - } else if (if_block_3) { - if_block_3.u(); - if_block_3.d(); - if_block_3 = null; - } - - if (state.e) { - if (!if_block_4) { - if_block_4 = create_if_block_4(component, state); - if_block_4.c(); - if_block_4.m(if_block_4_anchor.parentNode, if_block_4_anchor); - } - } else if (if_block_4) { - if_block_4.u(); - if_block_4.d(); - if_block_4 = null; - } - }, - - u: function unmount() { - detachNode(div); - if (if_block) if_block.u(); - if (if_block_1) if_block_1.u(); - if (if_block_2) if_block_2.u(); - if (if_block_3) if_block_3.u(); - detachNode(text_8); - if (if_block_4) if_block_4.u(); - detachNode(if_block_4_anchor); - }, - - d: function destroy$$1() { - if (if_block) if_block.d(); - if (if_block_1) if_block_1.d(); - if (if_block_2) if_block_2.d(); - if (if_block_3) if_block_3.d(); - if (if_block_4) if_block_4.d(); - } - }; -} - -// (2:1) {#if a} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "a"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (8:1) {#if b} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "b"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (12:1) {#if c} -function create_if_block_2(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "c"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (18:1) {#if d} -function create_if_block_3(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "d"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (25:0) {#if e} -function create_if_block_4(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "e"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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 index f0eea45d7743..1fda063de122 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -281,7 +281,7 @@ function create_main_fragment(component, state) { }; } -// (2:1) {{#if a}} +// (2:1) {#if a} function create_if_block(component, state) { var p; @@ -303,7 +303,7 @@ function create_if_block(component, state) { }; } -// (8:1) {{#if b}} +// (8:1) {#if b} function create_if_block_1(component, state) { var p; @@ -325,7 +325,7 @@ function create_if_block_1(component, state) { }; } -// (12:1) {{#if c}} +// (12:1) {#if c} function create_if_block_2(component, state) { var p; @@ -347,7 +347,7 @@ function create_if_block_2(component, state) { }; } -// (18:1) {{#if d}} +// (18:1) {#if d} function create_if_block_3(component, state) { var p; @@ -369,7 +369,7 @@ function create_if_block_3(component, state) { }; } -// (25:0) {{#if e}} +// (25:0) {#if e} function create_if_block_4(component, state) { var p; diff --git a/test/js/samples/use-elements-as-anchors/expected-v2.js b/test/js/samples/use-elements-as-anchors/expected-v2.js deleted file mode 100644 index d9cff08d3f98..000000000000 --- a/test/js/samples/use-elements-as-anchors/expected-v2.js +++ /dev/null @@ -1,262 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createComment, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var div, text, p, text_2, text_3, text_4, p_1, text_6, text_8, if_block_4_anchor; - - var if_block = (state.a) && create_if_block(component, state); - - var if_block_1 = (state.b) && create_if_block_1(component, state); - - var if_block_2 = (state.c) && create_if_block_2(component, state); - - var if_block_3 = (state.d) && create_if_block_3(component, state); - - var if_block_4 = (state.e) && create_if_block_4(component, state); - - return { - c: function create() { - div = createElement("div"); - if (if_block) if_block.c(); - text = createText("\n\n\t"); - p = createElement("p"); - p.textContent = "this can be used as an anchor"; - text_2 = createText("\n\n\t"); - if (if_block_1) if_block_1.c(); - text_3 = createText("\n\n\t"); - if (if_block_2) if_block_2.c(); - text_4 = createText("\n\n\t"); - p_1 = createElement("p"); - p_1.textContent = "so can this"; - text_6 = createText("\n\n\t"); - if (if_block_3) if_block_3.c(); - text_8 = createText("\n\n"); - if (if_block_4) if_block_4.c(); - if_block_4_anchor = createComment(); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - if (if_block) if_block.m(div, null); - appendNode(text, div); - appendNode(p, div); - appendNode(text_2, div); - if (if_block_1) if_block_1.m(div, null); - appendNode(text_3, div); - if (if_block_2) if_block_2.m(div, null); - appendNode(text_4, div); - appendNode(p_1, div); - appendNode(text_6, div); - if (if_block_3) if_block_3.m(div, null); - insertNode(text_8, target, anchor); - if (if_block_4) if_block_4.m(target, anchor); - insertNode(if_block_4_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.a) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(div, text); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - - if (state.b) { - if (!if_block_1) { - if_block_1 = create_if_block_1(component, state); - if_block_1.c(); - if_block_1.m(div, text_3); - } - } else if (if_block_1) { - if_block_1.u(); - if_block_1.d(); - if_block_1 = null; - } - - if (state.c) { - if (!if_block_2) { - if_block_2 = create_if_block_2(component, state); - if_block_2.c(); - if_block_2.m(div, text_4); - } - } else if (if_block_2) { - if_block_2.u(); - if_block_2.d(); - if_block_2 = null; - } - - if (state.d) { - if (!if_block_3) { - if_block_3 = create_if_block_3(component, state); - if_block_3.c(); - if_block_3.m(div, null); - } - } else if (if_block_3) { - if_block_3.u(); - if_block_3.d(); - if_block_3 = null; - } - - if (state.e) { - if (!if_block_4) { - if_block_4 = create_if_block_4(component, state); - if_block_4.c(); - if_block_4.m(if_block_4_anchor.parentNode, if_block_4_anchor); - } - } else if (if_block_4) { - if_block_4.u(); - if_block_4.d(); - if_block_4 = null; - } - }, - - u: function unmount() { - detachNode(div); - if (if_block) if_block.u(); - if (if_block_1) if_block_1.u(); - if (if_block_2) if_block_2.u(); - if (if_block_3) if_block_3.u(); - detachNode(text_8); - if (if_block_4) if_block_4.u(); - detachNode(if_block_4_anchor); - }, - - d: function destroy() { - if (if_block) if_block.d(); - if (if_block_1) if_block_1.d(); - if (if_block_2) if_block_2.d(); - if (if_block_3) if_block_3.d(); - if (if_block_4) if_block_4.d(); - } - }; -} - -// (2:1) {#if a} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "a"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (8:1) {#if b} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "b"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (12:1) {#if c} -function create_if_block_2(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "c"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (18:1) {#if d} -function create_if_block_3(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "d"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (25:0) {#if e} -function create_if_block_4(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "e"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - 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; \ No newline at end of file diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js index 5f6f27c742b6..d9cff08d3f98 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -136,7 +136,7 @@ function create_main_fragment(component, state) { }; } -// (2:1) {{#if a}} +// (2:1) {#if a} function create_if_block(component, state) { var p; @@ -158,7 +158,7 @@ function create_if_block(component, state) { }; } -// (8:1) {{#if b}} +// (8:1) {#if b} function create_if_block_1(component, state) { var p; @@ -180,7 +180,7 @@ function create_if_block_1(component, state) { }; } -// (12:1) {{#if c}} +// (12:1) {#if c} function create_if_block_2(component, state) { var p; @@ -202,7 +202,7 @@ function create_if_block_2(component, state) { }; } -// (18:1) {{#if d}} +// (18:1) {#if d} function create_if_block_3(component, state) { var p; @@ -224,7 +224,7 @@ function create_if_block_3(component, state) { }; } -// (25:0) {{#if e}} +// (25:0) {#if e} function create_if_block_4(component, state) { var p; diff --git a/test/js/samples/use-elements-as-anchors/input-v2.html b/test/js/samples/use-elements-as-anchors/input-v2.html deleted file mode 100644 index 9c18d40f582b..000000000000 --- a/test/js/samples/use-elements-as-anchors/input-v2.html +++ /dev/null @@ -1,27 +0,0 @@ -
- {#if a} -

a

- {/if} - -

this can be used as an anchor

- - {#if b} -

b

- {/if} - - {#if c} -

c

- {/if} - -

so can this

- - {#if d} -

d

- {/if} - - -
- -{#if e} -

e

-{/if} \ No newline at end of file diff --git a/test/js/samples/use-elements-as-anchors/input.html b/test/js/samples/use-elements-as-anchors/input.html index c55e7bd4de7b..9c18d40f582b 100644 --- a/test/js/samples/use-elements-as-anchors/input.html +++ b/test/js/samples/use-elements-as-anchors/input.html @@ -1,27 +1,27 @@
- {{#if a}} + {#if a}

a

- {{/if}} + {/if}

this can be used as an anchor

- {{#if b}} + {#if b}

b

- {{/if}} + {/if} - {{#if c}} + {#if c}

c

- {{/if}} + {/if}

so can this

- {{#if d}} + {#if d}

d

- {{/if}} + {/if}
-{{#if e}} +{#if e}

e

-{{/if}} \ No newline at end of file +{/if} \ No newline at end of file diff --git a/test/js/samples/window-binding-scroll/_actual-bundle-v2.js b/test/js/samples/window-binding-scroll/_actual-bundle-v2.js deleted file mode 100644 index deb99a4bb870..000000000000 --- a/test/js/samples/window-binding-scroll/_actual-bundle-v2.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 appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var window_updating = false, clear_window_updating = function() { window_updating = false; }, window_updating_timeout, p, text, text_1; - - function onwindowscroll(event) { - if (window_updating) return; - window_updating = true; - - component.set({ - y: this.pageYOffset - }); - window_updating = false; - } - window.addEventListener("scroll", onwindowscroll); - - component.observe("y", function(y) { - window_updating = true; - clearTimeout(window_updating_timeout); - window.scrollTo(window.pageXOffset, y); - window_updating_timeout = setTimeout(clear_window_updating, 100); - }); - - return { - c: function create() { - p = createElement("p"); - text = createText("scrolled to "); - text_1 = createText(state.y); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - if (changed.y) { - text_1.data = state.y; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: function destroy$$1() { - window.removeEventListener("scroll", onwindowscroll); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._state.y = window.pageYOffset; - - 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-v2.js b/test/js/samples/window-binding-scroll/expected-bundle-v2.js deleted file mode 100644 index deb99a4bb870..000000000000 --- a/test/js/samples/window-binding-scroll/expected-bundle-v2.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 appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, 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 = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -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) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get() { - return this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -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; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - 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 callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy, - get, - fire, - on, - set, - _recompute: noop, - _set, - _mount, - _unmount, - _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var window_updating = false, clear_window_updating = function() { window_updating = false; }, window_updating_timeout, p, text, text_1; - - function onwindowscroll(event) { - if (window_updating) return; - window_updating = true; - - component.set({ - y: this.pageYOffset - }); - window_updating = false; - } - window.addEventListener("scroll", onwindowscroll); - - component.observe("y", function(y) { - window_updating = true; - clearTimeout(window_updating_timeout); - window.scrollTo(window.pageXOffset, y); - window_updating_timeout = setTimeout(clear_window_updating, 100); - }); - - return { - c: function create() { - p = createElement("p"); - text = createText("scrolled to "); - text_1 = createText(state.y); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - if (changed.y) { - text_1.data = state.y; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: function destroy$$1() { - window.removeEventListener("scroll", onwindowscroll); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._state.y = window.pageYOffset; - - 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-v2.js b/test/js/samples/window-binding-scroll/expected-v2.js deleted file mode 100644 index 59009aeb9b99..000000000000 --- a/test/js/samples/window-binding-scroll/expected-v2.js +++ /dev/null @@ -1,68 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, createText, detachNode, init, insertNode, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var window_updating = false, clear_window_updating = function() { window_updating = false; }, window_updating_timeout, p, text, text_1; - - function onwindowscroll(event) { - if (window_updating) return; - window_updating = true; - - component.set({ - y: this.pageYOffset - }); - window_updating = false; - } - window.addEventListener("scroll", onwindowscroll); - - component.observe("y", function(y) { - window_updating = true; - clearTimeout(window_updating_timeout); - window.scrollTo(window.pageXOffset, y); - window_updating_timeout = setTimeout(clear_window_updating, 100); - }); - - return { - c: function create() { - p = createElement("p"); - text = createText("scrolled to "); - text_1 = createText(state.y); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - if (changed.y) { - text_1.data = state.y; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: function destroy() { - window.removeEventListener("scroll", onwindowscroll); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._state.y = window.pageYOffset; - - 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; \ No newline at end of file diff --git a/test/js/samples/window-binding-scroll/input-v2.html b/test/js/samples/window-binding-scroll/input-v2.html deleted file mode 100644 index 74ace567ab20..000000000000 --- a/test/js/samples/window-binding-scroll/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -<:Window bind:scrollY=y/> - -

scrolled to {y}

\ No newline at end of file diff --git a/test/js/samples/window-binding-scroll/input.html b/test/js/samples/window-binding-scroll/input.html index 2365bfcc9622..74ace567ab20 100644 --- a/test/js/samples/window-binding-scroll/input.html +++ b/test/js/samples/window-binding-scroll/input.html @@ -1,3 +1,3 @@ <:Window bind:scrollY=y/> -

scrolled to {{y}}

\ No newline at end of file +

scrolled to {y}

\ No newline at end of file From ce114600d1b92af9a8b6b1bbf9710c10c8a4d61a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 21:17:17 -0400 Subject: [PATCH 15/40] remove deprecated renderCss method --- src/generators/server-side-rendering/index.ts | 41 ------------------- .../ssr-no-oncreate-etc/expected-bundle.js | 16 -------- .../samples/ssr-no-oncreate-etc/expected.js | 14 ------- .../ssr-preserve-comments/expected-bundle.js | 16 -------- .../samples/ssr-preserve-comments/expected.js | 14 ------- 5 files changed, 101 deletions(-) diff --git a/src/generators/server-side-rendering/index.ts b/src/generators/server-side-rendering/index.ts index 3d83ddfb5bdc..4006379b1ef7 100644 --- a/src/generators/server-side-rendering/index.ts +++ b/src/generators/server-side-rendering/index.ts @@ -163,47 +163,6 @@ export default function ssr( }; var warned = false; - ${name}.renderCss = function() { - if (!warned) { - console.error('Component.renderCss(...) is deprecated and will be removed in v2 — use Component.render(...).css instead'); - warned = true; - } - - var components = []; - - ${generator.stylesheet.hasStyles && - deindent` - components.push({ - filename: ${name}.filename, - css: ${name}.css && ${name}.css.code, - map: ${name}.css && ${name}.css.map - }); - `} - - ${templateProperties.components && - deindent` - var seen = {}; - - function addComponent(component) { - var result = component.renderCss(); - result.components.forEach(x => { - if (seen[x.filename]) return; - seen[x.filename] = true; - components.push(x); - }); - } - - ${templateProperties.components.value.properties.map((prop: Node) => { - return `addComponent(%components-${getName(prop.key)});`; - })} - `} - - return { - css: components.map(x => x.css).join('\\n'), - map: null, - components - }; - }; ${templateProperties.preload && `${name}.preload = %preload;`} diff --git a/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js b/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js index 13c64c9d6cb6..b1d2e97e041c 100644 --- a/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js +++ b/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js @@ -41,22 +41,6 @@ SvelteComponent.css = { map: null }; -var warned = false; -SvelteComponent.renderCss = function() { - if (!warned) { - console.error('Component.renderCss(...) is deprecated and will be removed in v2 — use Component.render(...).css instead'); - warned = true; - } - - var components = []; - - return { - css: components.map(x => x.css).join('\n'), - map: null, - components - }; -}; - SvelteComponent.preload = preload; module.exports = SvelteComponent; diff --git a/test/js/samples/ssr-no-oncreate-etc/expected.js b/test/js/samples/ssr-no-oncreate-etc/expected.js index d9b616e76303..0aec3a587496 100644 --- a/test/js/samples/ssr-no-oncreate-etc/expected.js +++ b/test/js/samples/ssr-no-oncreate-etc/expected.js @@ -46,20 +46,6 @@ SvelteComponent.css = { }; var warned = false; -SvelteComponent.renderCss = function() { - if (!warned) { - console.error('Component.renderCss(...) is deprecated and will be removed in v2 — use Component.render(...).css instead'); - warned = true; - } - - var components = []; - - return { - css: components.map(x => x.css).join('\n'), - map: null, - components - }; -}; SvelteComponent.preload = preload; diff --git a/test/js/samples/ssr-preserve-comments/expected-bundle.js b/test/js/samples/ssr-preserve-comments/expected-bundle.js index 19461df02059..7ccd01cbefe5 100644 --- a/test/js/samples/ssr-preserve-comments/expected-bundle.js +++ b/test/js/samples/ssr-preserve-comments/expected-bundle.js @@ -40,20 +40,4 @@ SvelteComponent.css = { map: null }; -var warned = false; -SvelteComponent.renderCss = function() { - if (!warned) { - console.error('Component.renderCss(...) is deprecated and will be removed in v2 — use Component.render(...).css instead'); - warned = true; - } - - var components = []; - - return { - css: components.map(x => x.css).join('\n'), - map: null, - components - }; -}; - module.exports = SvelteComponent; diff --git a/test/js/samples/ssr-preserve-comments/expected.js b/test/js/samples/ssr-preserve-comments/expected.js index 3497a7283298..a67287968554 100644 --- a/test/js/samples/ssr-preserve-comments/expected.js +++ b/test/js/samples/ssr-preserve-comments/expected.js @@ -44,19 +44,5 @@ SvelteComponent.css = { }; var warned = false; -SvelteComponent.renderCss = function() { - if (!warned) { - console.error('Component.renderCss(...) is deprecated and will be removed in v2 — use Component.render(...).css instead'); - warned = true; - } - - var components = []; - - return { - css: components.map(x => x.css).join('\n'), - map: null, - components - }; -}; module.exports = SvelteComponent; \ No newline at end of file From 4b3da75480109fb8bf6562584252bedd97a9ca06 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 22:15:08 -0400 Subject: [PATCH 16/40] remove v1 runtime tests --- test/runtime/index.js | 20 +++---- test/runtime/samples/action-this/main.html | 2 +- .../samples/action-update/main-v2.html | 52 ------------------- test/runtime/samples/action-update/main.html | 4 +- .../samples/attribute-boolean-false/main.html | 2 +- .../attribute-boolean-indeterminate/main.html | 2 +- .../samples/attribute-boolean-true/main.html | 2 +- .../attribute-dynamic-multiple/main.html | 6 +-- .../attribute-dynamic-quotemarks/main.html | 2 +- .../attribute-dynamic-reserved/main.html | 2 +- .../attribute-dynamic-shorthand/main-v2.html | 9 ---- .../attribute-dynamic-shorthand/main.html | 2 +- .../samples/attribute-dynamic-type/main.html | 2 +- .../samples/attribute-dynamic/main.html | 2 +- .../samples/attribute-namespaced/main.html | 2 +- .../attribute-partial-number/Component.html | 2 +- .../attribute-prefer-expression/main.html | 4 +- test/runtime/samples/autofocus/main.html | 4 +- .../samples/await-component-oncreate/Foo.html | 4 +- .../await-component-oncreate/main.html | 6 +-- .../samples/await-set-simultaneous/main.html | 14 ++--- .../samples/await-then-catch-anchor/main.html | 12 ++--- .../samples/await-then-catch-event/main.html | 10 ++-- .../samples/await-then-catch-if/main.html | 18 +++---- .../await-then-catch-in-slot/main.html | 12 ++--- .../await-then-catch-multiple/main.html | 24 ++++----- .../await-then-catch-non-promise/main.html | 12 ++--- .../samples/await-then-catch/main.html | 12 ++--- .../samples/await-then-shorthand/main.html | 10 ++-- .../binding-indirect-computed/main.html | 10 ++-- .../samples/binding-indirect/main.html | 14 ++--- .../main.html | 10 ++-- .../main.html | 8 +-- .../binding-input-checkbox-group/main.html | 8 +-- .../main.html | 4 +- .../samples/binding-input-checkbox/main.html | 2 +- .../samples/binding-input-number/main.html | 2 +- .../binding-input-radio-group/main.html | 8 +-- .../binding-input-range-change/main.html | 2 +- .../samples/binding-input-range/main.html | 2 +- .../binding-input-text-contextual/main.html | 6 +-- .../binding-input-text-deconflicted/main.html | 2 +- .../main.html | 2 +- .../main.html | 2 +- .../main.html | 6 +-- .../main.html | 6 +-- .../samples/binding-input-text-deep/main.html | 2 +- .../samples/binding-input-text/main.html | 2 +- .../main.html | 8 +-- .../binding-select-in-each-block/main.html | 4 +- .../binding-select-in-yield/Modal.html | 4 +- .../samples/binding-select-in-yield/main.html | 8 +-- .../main.html | 4 +- .../binding-select-initial-value/main.html | 4 +- .../samples/binding-select-late/main.html | 8 +-- .../samples/binding-select-multiple/main.html | 2 +- .../samples/binding-select-optgroup/main.html | 2 +- test/runtime/samples/binding-select/main.html | 4 +- .../samples/binding-textarea/main.html | 2 +- .../samples/bindings-before-oncreate/Two.html | 2 +- .../samples/bindings-coalesced/Foo.html | 4 +- .../samples/bindings-coalesced/main.html | 2 +- .../component-binding-blowback-b/main.html | 10 ++-- .../component-binding-blowback-c/Nested.html | 2 +- .../component-binding-blowback-c/main.html | 10 ++-- .../component-binding-blowback/main.html | 4 +- .../component-binding-computed/Nested.html | 2 +- .../component-binding-computed/main.html | 6 +-- .../component-binding-conditional-b/Bar.html | 2 +- .../component-binding-conditional-b/Foo.html | 2 +- .../component-binding-conditional-b/main.html | 8 +-- .../component-binding-conditional/Bar.html | 2 +- .../component-binding-conditional/Foo.html | 2 +- .../component-binding-conditional/main.html | 8 +-- .../ComponentSelector.html | 6 +-- .../component-binding-deep-b/main.html | 4 +- .../samples/component-binding-deep/main.html | 2 +- .../component-binding-each-nested/main.html | 6 +-- .../component-binding-each-object/Widget.html | 2 +- .../component-binding-each-object/main.html | 4 +- .../samples/component-binding-each/main.html | 6 +-- .../component-binding-infinite-loop/B.html | 8 +-- .../component-binding-infinite-loop/C.html | 6 +-- .../samples/component-binding-nested/Bar.html | 2 +- .../samples/component-binding-nested/Baz.html | 2 +- .../samples/component-binding-nested/Foo.html | 2 +- .../component-binding-nested/main.html | 2 +- .../main.html | 2 +- .../main.html | 6 +-- .../samples/component-binding/main.html | 2 +- .../component-data-dynamic-late/Widget.html | 2 +- .../component-data-dynamic-late/main.html | 6 +-- .../Widget.html | 2 +- .../main.html | 2 +- .../component-data-dynamic/Widget.html | 8 +-- .../samples/component-data-dynamic/main.html | 2 +- .../samples/component-data-empty/Widget.html | 2 +- .../Link.html | 2 +- .../component-data-static-boolean/Foo.html | 2 +- .../samples/component-data-static/Widget.html | 4 +- .../samples/component-data-static/main.html | 2 +- .../samples/component-events-each/main.html | 4 +- .../samples/component-events/main.html | 4 +- .../component-if-placement/Component.html | 4 +- .../samples/component-if-placement/main.html | 6 +-- .../component-name-deconflicted/Nested.html | 2 +- .../component-name-deconflicted/main.html | 10 ++-- .../samples/component-nested-deep/Level2.html | 2 +- .../component-nested-deeper/Level1.html | 8 +-- .../component-nested-deeper/Level2.html | 10 ++-- .../component-nested-deeper/Level3.html | 2 +- .../samples/component-nested-deeper/main.html | 2 +- .../samples/component-not-void/Link.html | 2 +- .../component-slot-dynamic/Nested.html | 2 +- .../component-slot-each-block/main.html | 6 +-- .../main.html | 4 +- .../samples/component-slot-if-block/main.html | 4 +- .../main.html | 6 +-- .../component-static-at-symbol/Email.html | 2 +- .../component-yield-follows-element/Foo.html | 2 +- .../samples/component-yield-if/Widget.html | 6 +-- .../samples/component-yield-if/main.html | 2 +- .../Widget.html | 2 +- .../main.html | 6 +-- .../Widget.html | 2 +- .../component-yield-multiple-in-if/main.html | 6 +-- .../component-yield-nested-if/Outer.html | 6 +-- .../component-yield-nested-if/main.html | 2 +- .../component-yield-parent/Widget.html | 2 +- .../samples/component-yield-parent/main.html | 2 +- .../component-yield-placement/Modal.html | 2 +- .../component-yield-placement/main.html | 6 +-- .../component-yield-static/Widget.html | 2 +- .../samples/component-yield-static/main.html | 2 +- .../runtime/samples/component-yield/main.html | 6 +-- .../samples/computed-function/main-v2.html | 20 ------- .../samples/computed-function/main.html | 4 +- .../computed-values-deconflicted/main-v2.html | 14 ----- .../computed-values-deconflicted/main.html | 4 +- .../computed-values-default/main-v2.html | 9 ---- .../samples/computed-values-default/main.html | 4 +- .../main-v2.html | 28 ---------- .../main.html | 6 +-- .../samples/computed-values/main-v2.html | 16 ------ .../runtime/samples/computed-values/main.html | 8 +-- test/runtime/samples/custom-method/main.html | 2 +- .../samples/deconflict-builtins/main.html | 2 +- .../deconflict-component-refs/main.html | 12 ++--- .../samples/deconflict-contexts/main.html | 6 +-- .../deconflict-elements-indexes/main.html | 6 +-- .../samples/deconflict-non-helpers/main.html | 4 +- .../samples/deconflict-template-1/main.html | 2 +- .../samples/deconflict-template-2/main.html | 2 +- .../runtime/samples/deconflict-vars/main.html | 2 +- .../samples/default-data-function/main.html | 2 +- .../samples/default-data-override/main.html | 2 +- test/runtime/samples/default-data/main.html | 2 +- .../main-v2.html | 13 ----- .../main.html | 2 +- .../samples/dev-warning-helper/main.html | 2 +- .../dev-warning-missing-data/main.html | 4 +- .../dev-warning-readonly-computed/main.html | 2 +- .../main-v2.html | 1 - .../main.html | 2 +- .../Green-v2.html | 1 - .../Green.html | 2 +- .../Red-v2.html | 1 - .../Red.html | 2 +- .../main-v2.html | 15 ------ .../main.html | 2 +- .../dynamic-component-bindings/main-v2.html | 12 ----- .../dynamic-component-bindings/main.html | 2 +- .../dynamic-component-events/main-v2.html | 12 ----- .../dynamic-component-events/main.html | 2 +- .../Bar-v2.html | 1 - .../dynamic-component-inside-element/Bar.html | 2 +- .../Foo-v2.html | 1 - .../dynamic-component-inside-element/Foo.html | 2 +- .../main-v2.html | 14 ----- .../main.html | 2 +- .../dynamic-component-ref/main-v2.html | 11 ---- .../samples/dynamic-component-ref/main.html | 2 +- .../dynamic-component-slot/main-v2.html | 45 ---------------- .../samples/dynamic-component-slot/main.html | 20 +++---- .../Bar-v2.html | 1 - .../Bar.html | 2 +- .../Foo-v2.html | 1 - .../Foo.html | 2 +- .../main-v2.html | 12 ----- .../main.html | 2 +- .../samples/dynamic-component/Bar.html | 2 +- .../samples/dynamic-component/Foo.html | 2 +- .../samples/dynamic-component/main.html | 2 +- .../each-block-array-literal/main.html | 6 +-- .../Nested.html | 10 ++-- .../main.html | 2 +- .../each-block-containing-if/main.html | 10 ++-- .../main.html | 4 +- .../each-block-destructured-array/main.html | 6 +-- .../each-block-dynamic-else-static/main.html | 8 +-- .../each-block-else-starts-empty/main.html | 10 ++-- .../runtime/samples/each-block-else/main.html | 10 ++-- .../samples/each-block-indexed/main.html | 6 +-- .../each-block-keyed-dynamic/main.html | 6 +-- .../samples/each-block-keyed-empty/main.html | 2 +- .../each-block-keyed-random-permute/main.html | 6 +-- .../each-block-keyed-siblings/main.html | 12 ++--- .../samples/each-block-keyed-static/main.html | 4 +- .../each-block-keyed-unshift/Nested.html | 2 +- .../each-block-keyed-unshift/main.html | 6 +-- .../samples/each-block-keyed/main-v2.html | 3 -- .../samples/each-block-keyed/main.html | 6 +-- .../each-block-random-permute/main.html | 6 +-- .../samples/each-block-static/main.html | 4 +- .../samples/each-block-text-node/main.html | 6 +-- test/runtime/samples/each-block/main.html | 6 +-- .../samples/each-blocks-expression/main.html | 6 +-- .../samples/each-blocks-nested-b/main.html | 10 ++-- .../samples/each-blocks-nested/main.html | 10 ++-- .../escape-template-literals/Widget.html | 2 +- .../escape-template-literals/main.html | 6 +-- .../event-handler-custom-context/main.html | 2 +- .../main.html | 10 ++-- .../event-handler-custom-each/main.html | 10 ++-- .../main.html | 2 +- .../samples/event-handler-custom/main.html | 2 +- .../event-handler-each-deconflicted/main.html | 10 ++-- .../samples/event-handler-each/main.html | 8 +-- .../samples/event-handler-hoisted/main.html | 4 +- .../samples/event-handler-removal/main.html | 4 +- .../samples/event-handler-sanitize/main.html | 4 +- test/runtime/samples/event-handler/main.html | 4 +- .../samples/flush-before-bindings/Nested.html | 8 +-- .../flush-before-bindings/Visibility.html | 2 +- .../samples/function-in-expression/main.html | 2 +- test/runtime/samples/get-state/main.html | 2 +- .../globals-accessible-directly/main.html | 2 +- .../globals-not-dereferenced/main.html | 2 +- .../main.html | 6 +-- .../globals-shadowed-by-data/main.html | 2 +- .../globals-shadowed-by-helpers/main.html | 2 +- .../samples/head-title-dynamic/main-v2.html | 4 -- .../samples/head-title-dynamic/main.html | 6 +-- .../samples/head-title-static/main-v2.html | 4 -- .../samples/head-title-static/main.html | 4 +- test/runtime/samples/hello-world/main.html | 2 +- .../helpers-not-call-expression/main.html | 2 +- test/runtime/samples/helpers/main.html | 2 +- .../samples/if-block-else-in-each/main.html | 10 ++-- test/runtime/samples/if-block-else/main.html | 12 ++--- .../samples/if-block-elseif-text/main.html | 2 +- .../runtime/samples/if-block-elseif/main.html | 8 +-- .../samples/if-block-expression/main.html | 4 +- test/runtime/samples/if-block-or/main.html | 4 +- .../runtime/samples/if-block-widget/main.html | 4 +- test/runtime/samples/if-block/main.html | 4 +- .../samples/if-in-keyed-each/main.html | 10 ++-- .../main.html | 4 +- .../ignore-unchanged-attribute/main.html | 4 +- .../samples/ignore-unchanged-raw/main.html | 4 +- .../samples/ignore-unchanged-tag/main.html | 4 +- .../samples/immutable-mutable/Nested.html | 2 +- .../samples/immutable-nested/Nested.html | 2 +- test/runtime/samples/immutable-root/main.html | 2 +- .../samples/initial-state-assign/main.html | 4 +- .../samples/inline-expressions/main.html | 2 +- .../names-deconflicted-nested/main.html | 10 ++-- .../samples/names-deconflicted/Widget.html | 2 +- .../samples/names-deconflicted/main.html | 6 +-- .../non-root-style-interpolation/_config.js | 52 ------------------- .../non-root-style-interpolation/main.html | 43 --------------- .../main.html | 4 +- .../main.html | 2 +- .../samples/observe-deferred/main.html | 2 +- .../oncreate-sibling-order/Nested.html | 2 +- .../ondestroy-before-cleanup/main.html | 4 +- test/runtime/samples/onrender-chain/Item.html | 2 +- test/runtime/samples/onrender-chain/List.html | 6 +-- .../ParentWidget.html | 2 +- .../Widget.html | 2 +- .../onrender-fires-when-ready/Widget.html | 2 +- .../onrender-fires-when-ready/main.html | 4 +- test/runtime/samples/onstate-event/main.html | 4 +- test/runtime/samples/onstate/main.html | 4 +- test/runtime/samples/onupdate/main.html | 2 +- .../samples/option-without-select/main.html | 2 +- test/runtime/samples/options/main.html | 2 +- .../paren-wrapped-expressions/main.html | 14 ++--- .../samples/raw-anchor-first-child/main.html | 2 +- .../raw-anchor-first-last-child/main.html | 2 +- .../samples/raw-anchor-last-child/main.html | 2 +- .../main.html | 2 +- .../samples/raw-anchor-next-sibling/main.html | 2 +- .../raw-anchor-previous-sibling/main.html | 2 +- .../samples/raw-mustaches-preserved/main.html | 2 +- test/runtime/samples/raw-mustaches/main.html | 2 +- test/runtime/samples/refs-unset/main.html | 6 +-- .../script-style-non-top-level/main-v2.html | 4 -- .../samples/select-bind-array/main.html | 6 +-- .../samples/select-bind-in-array/main.html | 4 +- .../samples/select-change-handler/main.html | 6 +-- .../select-one-way-bind-object/main.html | 6 +-- .../samples/select-one-way-bind/main.html | 2 +- test/runtime/samples/select-props/main.html | 4 +- test/runtime/samples/select/main.html | 2 +- .../samples/self-reference-tree/main-v2.html | 11 ---- .../samples/self-reference-tree/main.html | 14 ++--- .../samples/self-reference/main-v2.html | 4 -- test/runtime/samples/self-reference/main.html | 8 +-- .../samples/set-after-destroy/main.html | 2 +- .../samples/set-clones-input/main.html | 2 +- .../runtime/samples/set-in-oncreate/main.html | 2 +- .../Widget.html | 2 +- .../set-in-onstate-dedupes-renders/main.html | 2 +- test/runtime/samples/set-in-onstate/main.html | 4 +- .../samples/set-mutated-data/main.html | 2 +- .../samples/set-prevents-loop/main.html | 6 +-- .../sigil-component-attribute/Widget.html | 2 +- .../sigil-component-attribute/main.html | 2 +- .../samples/spread-component-dynamic/Foo.html | 2 +- .../spread-component-dynamic/main.html | 2 +- .../samples/spread-component/Widget.html | 8 +-- .../samples/spread-component/main.html | 2 +- .../samples/spread-element-boolean/main.html | 2 +- .../samples/spread-element-multiple/main.html | 2 +- test/runtime/samples/spread-element/main.html | 2 +- .../samples/state-deconflicted/main.html | 8 +-- test/runtime/samples/store-binding/main.html | 2 +- .../store-component-binding-deep/main.html | 2 +- .../store-component-binding-each/main.html | 6 +-- .../samples/store-component-binding/main.html | 2 +- test/runtime/samples/store-computed/Todo.html | 8 +-- test/runtime/samples/store-computed/main.html | 6 +-- test/runtime/samples/store-event/main.html | 2 +- test/runtime/samples/store-nested/Nested.html | 2 +- .../samples/store-onstate-dollar/main.html | 2 +- test/runtime/samples/store-root/Nested.html | 2 +- test/runtime/samples/store-root/main.html | 2 +- test/runtime/samples/store/main.html | 2 +- .../Rect.html | 2 +- .../main.html | 2 +- .../Rect.html | 2 +- .../main.html | 2 +- .../Rect.html | 2 +- .../main.html | 2 +- .../samples/svg-each-block-anchor/main.html | 8 +-- .../svg-each-block-namespace/main.html | 6 +-- test/runtime/samples/svg-multiple/main.html | 4 +- test/runtime/samples/svg-with-style/main.html | 2 +- test/runtime/samples/svg-xmlns/main.html | 2 +- test/runtime/samples/svg/main.html | 2 +- .../samples/textarea-children/main.html | 2 +- test/runtime/samples/textarea-value/main.html | 2 +- .../samples/transition-css-delay/main.html | 4 +- .../samples/transition-css-duration/main.html | 4 +- .../transition-js-delay-in-out/main.html | 4 +- .../samples/transition-js-delay/main.html | 4 +- .../main.html | 6 +-- .../main.html | 10 ++-- .../transition-js-each-block-intro/main.html | 6 +-- .../main.html | 6 +-- .../main.html | 6 +-- .../main.html | 6 +-- .../transition-js-each-block-outro/main.html | 6 +-- .../samples/transition-js-events/main.html | 10 ++-- .../transition-js-if-block-bidi/main.html | 4 +- .../main.html | 22 ++++---- .../main.html | 22 ++++---- .../main.html | 10 ++-- .../main.html | 4 +- .../transition-js-if-block-intro/main.html | 4 +- .../main.html | 10 ++-- .../main.html | 6 +-- .../main.html | 6 +-- .../main.html | 6 +-- .../transition-js-nested-intro/main.html | 4 +- .../main.html | 4 +- .../transition-js-parameterised/main.html | 4 +- .../samples/whitespace-each-block/main.html | 2 +- .../samples/whitespace-normal/main.html | 6 +-- .../window-bind-scroll-update/main-v2.html | 3 -- .../window-bind-scroll-update/main.html | 2 +- .../window-binding-resize/main-v2.html | 3 -- .../samples/window-binding-resize/main.html | 4 +- .../samples/window-event-context/main-v2.html | 3 -- .../samples/window-event-context/main.html | 4 +- .../samples/window-event-custom/main-v2.html | 25 --------- .../samples/window-event-custom/main.html | 4 +- test/runtime/samples/window-event/main.html | 4 +- 389 files changed, 809 insertions(+), 1261 deletions(-) delete mode 100644 test/runtime/samples/action-update/main-v2.html delete mode 100644 test/runtime/samples/attribute-dynamic-shorthand/main-v2.html delete mode 100644 test/runtime/samples/computed-function/main-v2.html delete mode 100644 test/runtime/samples/computed-values-deconflicted/main-v2.html delete mode 100644 test/runtime/samples/computed-values-default/main-v2.html delete mode 100644 test/runtime/samples/computed-values-function-dependency/main-v2.html delete mode 100644 test/runtime/samples/computed-values/main-v2.html delete mode 100644 test/runtime/samples/dev-warning-dynamic-components-misplaced/main-v2.html delete mode 100644 test/runtime/samples/dev-warning-readonly-window-binding/main-v2.html delete mode 100644 test/runtime/samples/dynamic-component-bindings-recreated/Green-v2.html delete mode 100644 test/runtime/samples/dynamic-component-bindings-recreated/Red-v2.html delete mode 100644 test/runtime/samples/dynamic-component-bindings-recreated/main-v2.html delete mode 100644 test/runtime/samples/dynamic-component-bindings/main-v2.html delete mode 100644 test/runtime/samples/dynamic-component-events/main-v2.html delete mode 100644 test/runtime/samples/dynamic-component-inside-element/Bar-v2.html delete mode 100644 test/runtime/samples/dynamic-component-inside-element/Foo-v2.html delete mode 100644 test/runtime/samples/dynamic-component-inside-element/main-v2.html delete mode 100644 test/runtime/samples/dynamic-component-ref/main-v2.html delete mode 100644 test/runtime/samples/dynamic-component-slot/main-v2.html delete mode 100644 test/runtime/samples/dynamic-component-update-existing-instance/Bar-v2.html delete mode 100644 test/runtime/samples/dynamic-component-update-existing-instance/Foo-v2.html delete mode 100644 test/runtime/samples/dynamic-component-update-existing-instance/main-v2.html delete mode 100644 test/runtime/samples/each-block-keyed/main-v2.html delete mode 100644 test/runtime/samples/head-title-dynamic/main-v2.html delete mode 100644 test/runtime/samples/head-title-static/main-v2.html delete mode 100644 test/runtime/samples/non-root-style-interpolation/_config.js delete mode 100644 test/runtime/samples/non-root-style-interpolation/main.html delete mode 100644 test/runtime/samples/script-style-non-top-level/main-v2.html delete mode 100644 test/runtime/samples/self-reference-tree/main-v2.html delete mode 100644 test/runtime/samples/self-reference/main-v2.html delete mode 100644 test/runtime/samples/window-bind-scroll-update/main-v2.html delete mode 100644 test/runtime/samples/window-binding-resize/main-v2.html delete mode 100644 test/runtime/samples/window-event-context/main-v2.html delete mode 100644 test/runtime/samples/window-event-custom/main-v2.html diff --git a/test/runtime/index.js b/test/runtime/index.js index 96d7ad644555..913fddacf2ad 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -21,11 +21,11 @@ let compileOptions = null; let compile = null; function getName(filename) { - const base = path.basename(filename).replace('-v2', '').replace(".html", ""); + const base = path.basename(filename).replace(".html", ""); return base[0].toUpperCase() + base.slice(1); } -describe("runtime", () => { +describe.only("runtime", () => { before(() => { svelte = loadSvelte(false); svelte$ = loadSvelte(true); @@ -46,7 +46,7 @@ describe("runtime", () => { const failed = new Set(); - function runTest(dir, shared, hydrate, v2) { + function runTest(dir, shared, hydrate) { if (dir[0] === ".") return; const config = loadConfig(`./runtime/samples/${dir}/_config.js`); @@ -55,7 +55,7 @@ describe("runtime", () => { throw new Error("Forgot to remove `solo: true` from test"); } - (config.skip ? it.skip : config.solo ? it.only : it)(`${dir} (${shared ? 'shared' : 'inline'} helpers${hydrate ? ', hydration' : ''}${v2 ? ', v2' : ''})`, () => { + (config.skip ? it.skip : config.solo ? it.only : it)(`${dir} (${shared ? 'shared' : 'inline'} helpers${hydrate ? ', hydration' : ''})`, () => { if (failed.has(dir)) { // this makes debugging easier, by only printing compiled output once throw new Error('skipping test, already failed'); @@ -72,7 +72,7 @@ describe("runtime", () => { compileOptions.dev = config.dev; compileOptions.store = !!config.store; compileOptions.immutable = config.immutable; - compileOptions.parser = v2 ? 'v2' : 'v1'; + compileOptions.parser = 'v2'; // TODO remove Object.keys(require.cache) .filter(x => x.endsWith(".html")) @@ -112,7 +112,7 @@ describe("runtime", () => { }; try { - SvelteComponent = require(`./samples/${dir}/main${v2 ? '-v2' : ''}.html`); + SvelteComponent = require(`./samples/${dir}/main.html`); } catch (err) { showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate, store: !!compileOptions.store }, compile); // eslint-disable-line no-console throw err; @@ -172,12 +172,12 @@ describe("runtime", () => { config.error(assert, err); } else { failed.add(dir); - showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate, store: !!compileOptions.store, v2 }, compile); // eslint-disable-line no-console + showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate, store: !!compileOptions.store, v2: true }, compile); // eslint-disable-line no-console throw err; } }) .then(() => { - if (config.show) showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate, store: !!compileOptions.store, v2 }, compile); + if (config.show) showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate, store: !!compileOptions.store, v2: true }, compile); }); }); } @@ -187,10 +187,6 @@ describe("runtime", () => { runTest(dir, shared, false); runTest(dir, shared, true); runTest(dir, null, false); - - if (fs.existsSync(`test/runtime/samples/${dir}/main-v2.html`)) { - runTest(dir, shared, false, true); - } }); it("fails if options.target is missing in dev mode", () => { diff --git a/test/runtime/samples/action-this/main.html b/test/runtime/samples/action-this/main.html index 95da3d4a8c77..6eb12e120630 100644 --- a/test/runtime/samples/action-this/main.html +++ b/test/runtime/samples/action-this/main.html @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/test/runtime/samples/action-update/main.html b/test/runtime/samples/action-update/main.html index 03bd0d0ef955..6b319f5dca3d 100644 --- a/test/runtime/samples/action-update/main.html +++ b/test/runtime/samples/action-update/main.html @@ -1,5 +1,5 @@ -<:Window on:keydown="checkForCtrl(event)" on:keyup="checkForCtrl(event)"/> + diff --git a/test/runtime/samples/attribute-dynamic-shorthand/main.html b/test/runtime/samples/attribute-dynamic-shorthand/main.html index 25b468a8f10e..9bbc47727246 100644 --- a/test/runtime/samples/attribute-dynamic-shorthand/main.html +++ b/test/runtime/samples/attribute-dynamic-shorthand/main.html @@ -1,4 +1,4 @@ -
+
\ No newline at end of file diff --git a/test/runtime/samples/binding-indirect/main.html b/test/runtime/samples/binding-indirect/main.html index e1ab12c82f3c..df37840b43fd 100644 --- a/test/runtime/samples/binding-indirect/main.html +++ b/test/runtime/samples/binding-indirect/main.html @@ -1,14 +1,14 @@

Pending tasks

-{{#each tasks.filter(t => !t.done) as task}} -

{{task.description}}

-{{/each}} \ No newline at end of file +{#each tasks.filter(t => !t.done) as task} +

{task.description}

+{/each} \ No newline at end of file diff --git a/test/runtime/samples/binding-input-checkbox-deep-contextual/main.html b/test/runtime/samples/binding-input-checkbox-deep-contextual/main.html index dc385a49901e..209cdbeaf72c 100644 --- a/test/runtime/samples/binding-input-checkbox-deep-contextual/main.html +++ b/test/runtime/samples/binding-input-checkbox-deep-contextual/main.html @@ -1,13 +1,13 @@ -{{#each items as item}} -

{{item.description}}

-{{/each}} +{#each items as item} +

{item.description}

+{/each} -

{{numCompleted}} completed

+

{numCompleted} completed

diff --git a/test/runtime/samples/computed-function/main.html b/test/runtime/samples/computed-function/main.html index f3fc14727d29..a43225216687 100644 --- a/test/runtime/samples/computed-function/main.html +++ b/test/runtime/samples/computed-function/main.html @@ -1,4 +1,4 @@ -

{{scale(x)}}

+

{scale(x)}

\ No newline at end of file diff --git a/test/runtime/samples/computed-values-deconflicted/main.html b/test/runtime/samples/computed-values-deconflicted/main.html index d32fde6167a6..e5a016084cad 100644 --- a/test/runtime/samples/computed-values-deconflicted/main.html +++ b/test/runtime/samples/computed-values-deconflicted/main.html @@ -1,4 +1,4 @@ -{{state}} +{state} \ No newline at end of file diff --git a/test/runtime/samples/computed-values-default/main-v2.html b/test/runtime/samples/computed-values-default/main-v2.html deleted file mode 100644 index b26762f3d826..000000000000 --- a/test/runtime/samples/computed-values-default/main-v2.html +++ /dev/null @@ -1,9 +0,0 @@ -

{foo}

- - diff --git a/test/runtime/samples/computed-values-default/main.html b/test/runtime/samples/computed-values-default/main.html index 74292a3a2e14..b26762f3d826 100644 --- a/test/runtime/samples/computed-values-default/main.html +++ b/test/runtime/samples/computed-values-default/main.html @@ -1,9 +1,9 @@ -

{{foo}}

+

{foo}

diff --git a/test/runtime/samples/computed-values-function-dependency/main-v2.html b/test/runtime/samples/computed-values-function-dependency/main-v2.html deleted file mode 100644 index adf66137fa8a..000000000000 --- a/test/runtime/samples/computed-values-function-dependency/main-v2.html +++ /dev/null @@ -1,28 +0,0 @@ -

{x}

- - \ No newline at end of file diff --git a/test/runtime/samples/computed-values-function-dependency/main.html b/test/runtime/samples/computed-values-function-dependency/main.html index d385bf6da896..adf66137fa8a 100644 --- a/test/runtime/samples/computed-values-function-dependency/main.html +++ b/test/runtime/samples/computed-values-function-dependency/main.html @@ -1,4 +1,4 @@ -

{{x}}

+

{x}

diff --git a/test/runtime/samples/computed-values/main.html b/test/runtime/samples/computed-values/main.html index 0cee54f8671e..7e4f8d772853 100644 --- a/test/runtime/samples/computed-values/main.html +++ b/test/runtime/samples/computed-values/main.html @@ -1,5 +1,5 @@ -

{{a}} + {{b}} = {{c}}

-

{{c}} * {{c}} = {{cSquared}}

+

{a} + {b} = {c}

+

{c} * {c} = {cSquared}

diff --git a/test/runtime/samples/custom-method/main.html b/test/runtime/samples/custom-method/main.html index 3bd8459fb1fa..0f1ad3387cb8 100644 --- a/test/runtime/samples/custom-method/main.html +++ b/test/runtime/samples/custom-method/main.html @@ -1,6 +1,6 @@ -

{{counter}}

+

{counter}

diff --git a/test/runtime/samples/deconflict-template-1/main.html b/test/runtime/samples/deconflict-template-1/main.html index f4fe8de42389..395d7b22b379 100644 --- a/test/runtime/samples/deconflict-template-1/main.html +++ b/test/runtime/samples/deconflict-template-1/main.html @@ -1,4 +1,4 @@ -{{value}} +{value} \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-dynamic-components-misplaced/main.html b/test/runtime/samples/dev-warning-dynamic-components-misplaced/main.html index 37392f27e6fd..eb6e7d8e8e61 100644 --- a/test/runtime/samples/dev-warning-dynamic-components-misplaced/main.html +++ b/test/runtime/samples/dev-warning-dynamic-components-misplaced/main.html @@ -1,4 +1,4 @@ -<:Component {x ? Foo : Bar}/> + \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-readonly-window-binding/main-v2.html b/test/runtime/samples/dev-warning-readonly-window-binding/main-v2.html deleted file mode 100644 index 87b0403ee32e..000000000000 --- a/test/runtime/samples/dev-warning-readonly-window-binding/main-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-readonly-window-binding/main.html b/test/runtime/samples/dev-warning-readonly-window-binding/main.html index 635ae75e9c3f..87b0403ee32e 100644 --- a/test/runtime/samples/dev-warning-readonly-window-binding/main.html +++ b/test/runtime/samples/dev-warning-readonly-window-binding/main.html @@ -1 +1 @@ -<:Window bind:innerWidth='width'/> \ No newline at end of file + \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/Green-v2.html b/test/runtime/samples/dynamic-component-bindings-recreated/Green-v2.html deleted file mode 100644 index b4faa1b66263..000000000000 --- a/test/runtime/samples/dynamic-component-bindings-recreated/Green-v2.html +++ /dev/null @@ -1 +0,0 @@ -

green {foo}

\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/Green.html b/test/runtime/samples/dynamic-component-bindings-recreated/Green.html index 692847c1c204..b4faa1b66263 100644 --- a/test/runtime/samples/dynamic-component-bindings-recreated/Green.html +++ b/test/runtime/samples/dynamic-component-bindings-recreated/Green.html @@ -1 +1 @@ -

green {{foo}}

\ No newline at end of file +

green {foo}

\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/Red-v2.html b/test/runtime/samples/dynamic-component-bindings-recreated/Red-v2.html deleted file mode 100644 index a3e3c792a03f..000000000000 --- a/test/runtime/samples/dynamic-component-bindings-recreated/Red-v2.html +++ /dev/null @@ -1 +0,0 @@ -

red {foo}

\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/Red.html b/test/runtime/samples/dynamic-component-bindings-recreated/Red.html index 8f10e3294dbe..a3e3c792a03f 100644 --- a/test/runtime/samples/dynamic-component-bindings-recreated/Red.html +++ b/test/runtime/samples/dynamic-component-bindings-recreated/Red.html @@ -1 +1 @@ -

red {{foo}}

\ No newline at end of file +

red {foo}

\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/main-v2.html b/test/runtime/samples/dynamic-component-bindings-recreated/main-v2.html deleted file mode 100644 index 6d748ed21705..000000000000 --- a/test/runtime/samples/dynamic-component-bindings-recreated/main-v2.html +++ /dev/null @@ -1,15 +0,0 @@ - - - \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/main.html b/test/runtime/samples/dynamic-component-bindings-recreated/main.html index b9cdf9266099..a26c1cd080d6 100644 --- a/test/runtime/samples/dynamic-component-bindings-recreated/main.html +++ b/test/runtime/samples/dynamic-component-bindings-recreated/main.html @@ -1,4 +1,4 @@ -<:Component {x ? Green : Red} bind:foo /> + \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings/main.html b/test/runtime/samples/dynamic-component-bindings/main.html index cb260da71fe2..020855cb2272 100644 --- a/test/runtime/samples/dynamic-component-bindings/main.html +++ b/test/runtime/samples/dynamic-component-bindings/main.html @@ -1,4 +1,4 @@ -<:Component { x ? Foo : Bar } bind:y bind:z/> + \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-events/main.html b/test/runtime/samples/dynamic-component-events/main.html index 8606b56ce069..5fa66b2c6135 100644 --- a/test/runtime/samples/dynamic-component-events/main.html +++ b/test/runtime/samples/dynamic-component-events/main.html @@ -1,4 +1,4 @@ -<:Component { x ? Foo : Bar } on:select='set({ selected: event.id })'/> + \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-inside-element/main.html b/test/runtime/samples/dynamic-component-inside-element/main.html index 2f2eb2658735..0844346301e2 100644 --- a/test/runtime/samples/dynamic-component-inside-element/main.html +++ b/test/runtime/samples/dynamic-component-inside-element/main.html @@ -1,5 +1,5 @@
- <:Component { x ? Foo : Bar } x='{{x}}'/> +
diff --git a/test/runtime/samples/dynamic-component-ref/main.html b/test/runtime/samples/dynamic-component-ref/main.html index ff506517bc9d..1d54b172995d 100644 --- a/test/runtime/samples/dynamic-component-ref/main.html +++ b/test/runtime/samples/dynamic-component-ref/main.html @@ -1,4 +1,4 @@ -<:Component {foo} ref:test/> + \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-slot/main.html b/test/runtime/samples/dynamic-component-slot/main.html index fd4fad13691b..e8b5c487ad3d 100644 --- a/test/runtime/samples/dynamic-component-slot/main.html +++ b/test/runtime/samples/dynamic-component-slot/main.html @@ -1,26 +1,26 @@ -<:Component { x ? Foo : Bar } x='{{x}}'> +

element

- {{tag}} + {tag} - {{#if foo}} + {#if foo}

foo

- {{elseif bar}} + {:elseif bar}

bar

- {{else}} + {:else}

neither foo nor bar

- {{/if}} + {/if} text - {{#each things as thing}} - {{thing}} - {{/each}} + {#each things as thing} + {thing} + {/each}
what goes up must come down
- +
\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-update-existing-instance/main.html b/test/runtime/samples/dynamic-component-update-existing-instance/main.html index 127c189cc316..1f8bd35f8cad 100644 --- a/test/runtime/samples/dynamic-component-update-existing-instance/main.html +++ b/test/runtime/samples/dynamic-component-update-existing-instance/main.html @@ -1,4 +1,4 @@ -<:Component { x ? Foo : Bar } x='{{x}}'/> + diff --git a/test/runtime/samples/globals-accessible-directly/main.html b/test/runtime/samples/globals-accessible-directly/main.html index 349b4b1d3292..77225fa117a5 100644 --- a/test/runtime/samples/globals-accessible-directly/main.html +++ b/test/runtime/samples/globals-accessible-directly/main.html @@ -1 +1 @@ -{{NaN}} +{NaN} diff --git a/test/runtime/samples/globals-not-dereferenced/main.html b/test/runtime/samples/globals-not-dereferenced/main.html index 771042ed0742..ec39251992cb 100644 --- a/test/runtime/samples/globals-not-dereferenced/main.html +++ b/test/runtime/samples/globals-not-dereferenced/main.html @@ -1 +1 @@ -{{Math.min(x, 5)}} +{Math.min(x, 5)} diff --git a/test/runtime/samples/globals-not-overwritten-by-bindings/main.html b/test/runtime/samples/globals-not-overwritten-by-bindings/main.html index ca6c6ccb3545..a8b873211ca2 100644 --- a/test/runtime/samples/globals-not-overwritten-by-bindings/main.html +++ b/test/runtime/samples/globals-not-overwritten-by-bindings/main.html @@ -1,6 +1,6 @@ -{{#each Object.keys(todos) as key}} -
+{#each Object.keys(todos) as key} +
-{{/each}} \ No newline at end of file +{/each} \ No newline at end of file diff --git a/test/runtime/samples/globals-shadowed-by-data/main.html b/test/runtime/samples/globals-shadowed-by-data/main.html index 73fd9437aff3..7e3b4083313a 100644 --- a/test/runtime/samples/globals-shadowed-by-data/main.html +++ b/test/runtime/samples/globals-shadowed-by-data/main.html @@ -1,4 +1,4 @@ -{{Math.min(x, 5)}} +{Math.min(x, 5)} -
\ No newline at end of file diff --git a/test/runtime/samples/select-bind-array/main.html b/test/runtime/samples/select-bind-array/main.html index 7971c4fe1017..67c1dfdb918e 100644 --- a/test/runtime/samples/select-bind-array/main.html +++ b/test/runtime/samples/select-bind-array/main.html @@ -1,5 +1,5 @@ diff --git a/test/runtime/samples/select-bind-in-array/main.html b/test/runtime/samples/select-bind-in-array/main.html index 1a80b1afa0a6..9a4d1e82cdea 100644 --- a/test/runtime/samples/select-bind-in-array/main.html +++ b/test/runtime/samples/select-bind-in-array/main.html @@ -1,6 +1,6 @@ -{{#each items as item}} +{#each items as item} -{{/each}} +{/each} diff --git a/test/runtime/samples/select-change-handler/main.html b/test/runtime/samples/select-change-handler/main.html index 48376dfa93fb..13d9bd75afe8 100644 --- a/test/runtime/samples/select-change-handler/main.html +++ b/test/runtime/samples/select-change-handler/main.html @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/test/runtime/samples/set-in-oncreate/main.html b/test/runtime/samples/set-in-oncreate/main.html index 8e71ec5905bf..77633574f1bd 100644 --- a/test/runtime/samples/set-in-oncreate/main.html +++ b/test/runtime/samples/set-in-oncreate/main.html @@ -1,4 +1,4 @@ -

{{foo}}

+

{foo}

\ No newline at end of file diff --git a/test/runtime/samples/window-event-custom/main.html b/test/runtime/samples/window-event-custom/main.html index af33d08d975a..515d5bc4caf0 100644 --- a/test/runtime/samples/window-event-custom/main.html +++ b/test/runtime/samples/window-event-custom/main.html @@ -1,6 +1,6 @@ -<:Window on:esc="set({ escaped: true })" /> + -

escaped: {{escaped}}

+

escaped: {escaped}

\ No newline at end of file diff --git a/test/runtime/index.js b/test/runtime/index.js index 913fddacf2ad..806b0dab7981 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -172,12 +172,12 @@ describe.only("runtime", () => { config.error(assert, err); } else { failed.add(dir); - showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate, store: !!compileOptions.store, v2: true }, compile); // eslint-disable-line no-console + showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate, store: !!compileOptions.store }, compile); // eslint-disable-line no-console throw err; } }) .then(() => { - if (config.show) showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate, store: !!compileOptions.store, v2: true }, compile); + if (config.show) showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate, store: !!compileOptions.store }, compile); }); }); } From 39ad124c99880c382bc80a063de9894522d9ee4f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 23:06:57 -0400 Subject: [PATCH 19/40] update validation tests --- test/runtime/index.js | 2 +- .../samples/a11y-html-has-lang/input.html | 2 +- .../samples/a11y-html-has-lang/warnings.json | 2 +- .../samples/a11y-iframe-has-title/input.html | 2 +- .../a11y-iframe-has-title/warnings.json | 2 +- .../a11y-tabindex-no-positive/input.html | 2 +- .../await-component-is-used/input.html | 12 ++--- .../binding-input-type-dynamic/errors.json | 2 +- .../binding-input-type-dynamic/input.html | 2 +- .../errors.json | 2 +- .../input.html | 2 +- .../errors.json | 2 +- .../input.html | 2 +- .../component-slot-dynamic/errors.json | 2 +- .../samples/component-slot-dynamic/input.html | 2 +- .../component-slot-each-block/errors.json | 2 +- .../component-slot-each-block/input.html | 4 +- .../component-slotted-each-block/errors.json | 2 +- .../component-slotted-each-block/input.html | 6 +-- .../component-slotted-if-block/errors.json | 2 +- .../component-slotted-if-block/input.html | 6 +-- .../computed-purity-check-no-this/errors.json | 2 +- .../computed-purity-check-no-this/input.html | 2 +- .../errors.json | 2 +- .../computed-purity-check-this-get/input.html | 2 +- .../errors.json | 6 +-- .../input.html | 6 +-- .../each-block-invalid-context/errors.json | 6 +-- .../each-block-invalid-context/input.html | 6 +-- .../each-block-multiple-children/input.html | 10 ++-- .../samples/empty-block-dev/input.html | 6 +-- .../samples/empty-block-dev/warnings.json | 6 +-- .../samples/empty-block-prod/input.html | 6 +-- .../samples/helper-clash-context/input.html | 6 +-- .../helper-clash-context/warnings.json | 6 +-- .../input.html | 2 +- .../warnings.json | 2 +- .../helper-purity-check-this-get/errors.json | 2 +- .../helper-purity-check-this-get/input.html | 2 +- .../input.html | 2 +- .../method-nonexistent-helper/warnings.json | 2 +- .../samples/method-nonexistent/warnings.json | 2 +- .../errors.json | 2 +- .../input.html | 2 +- .../errors.json | 2 +- .../input.html | 2 +- .../errors.json | 13 ----- .../input.html | 9 ---- .../samples/store-unexpected/input.html | 1 - .../samples/store-unexpected/warnings.json | 13 ----- .../input.html | 2 +- .../input.html | 30 +---------- .../warnings.json | 54 +------------------ .../textarea-value-children/errors.json | 2 +- .../textarea-value-children/input.html | 2 +- .../title-no-attributes/errors-v2.json | 13 ----- .../samples/title-no-attributes/errors.json | 2 +- .../samples/title-no-attributes/input-v2.html | 3 -- .../samples/title-no-attributes/input.html | 4 +- .../samples/title-no-children/errors.json | 2 +- .../samples/title-no-children/input.html | 4 +- .../errors.json | 6 +-- .../input.html | 2 +- .../window-binding-invalid-value/errors.json | 6 +-- .../window-binding-invalid-value/input.html | 2 +- .../window-binding-invalid-width/errors.json | 6 +-- .../window-binding-invalid-width/input.html | 2 +- .../window-binding-invalid/errors.json | 6 +-- .../samples/window-binding-invalid/input.html | 2 +- .../samples/window-binding-online/input.html | 2 +- .../samples/window-event-invalid/input.html | 2 +- .../window-event-invalid/warnings.json | 8 +-- 72 files changed, 111 insertions(+), 243 deletions(-) delete mode 100644 test/validator/samples/properties-computed-no-destructuring/errors.json delete mode 100644 test/validator/samples/properties-computed-no-destructuring/input.html delete mode 100644 test/validator/samples/store-unexpected/input.html delete mode 100644 test/validator/samples/store-unexpected/warnings.json delete mode 100644 test/validator/samples/title-no-attributes/errors-v2.json delete mode 100644 test/validator/samples/title-no-attributes/input-v2.html diff --git a/test/runtime/index.js b/test/runtime/index.js index 806b0dab7981..109615f30941 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -25,7 +25,7 @@ function getName(filename) { return base[0].toUpperCase() + base.slice(1); } -describe.only("runtime", () => { +describe("runtime", () => { before(() => { svelte = loadSvelte(false); svelte$ = loadSvelte(true); diff --git a/test/validator/samples/a11y-html-has-lang/input.html b/test/validator/samples/a11y-html-has-lang/input.html index 41f2fc627662..0fa84d90a600 100644 --- a/test/validator/samples/a11y-html-has-lang/input.html +++ b/test/validator/samples/a11y-html-has-lang/input.html @@ -1,5 +1,5 @@ - + diff --git a/test/validator/samples/a11y-html-has-lang/warnings.json b/test/validator/samples/a11y-html-has-lang/warnings.json index c8c7c51cc6e1..71892967252f 100644 --- a/test/validator/samples/a11y-html-has-lang/warnings.json +++ b/test/validator/samples/a11y-html-has-lang/warnings.json @@ -10,6 +10,6 @@ "line": 5, "column": 13 }, - "pos": 84 + "pos": 82 } ] diff --git a/test/validator/samples/a11y-iframe-has-title/input.html b/test/validator/samples/a11y-iframe-has-title/input.html index 2b5060b80eae..5e07ca5a0815 100644 --- a/test/validator/samples/a11y-iframe-has-title/input.html +++ b/test/validator/samples/a11y-iframe-has-title/input.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/test/validator/samples/a11y-iframe-has-title/warnings.json b/test/validator/samples/a11y-iframe-has-title/warnings.json index 33706158df66..3dc5a6644ae0 100644 --- a/test/validator/samples/a11y-iframe-has-title/warnings.json +++ b/test/validator/samples/a11y-iframe-has-title/warnings.json @@ -8,7 +8,7 @@ }, "end": { "line": 1, - "column": 31 + "column": 29 }, "pos": 0 } diff --git a/test/validator/samples/a11y-tabindex-no-positive/input.html b/test/validator/samples/a11y-tabindex-no-positive/input.html index fa34d69f2d29..e922078221d7 100644 --- a/test/validator/samples/a11y-tabindex-no-positive/input.html +++ b/test/validator/samples/a11y-tabindex-no-positive/input.html @@ -1,4 +1,4 @@
-
\ No newline at end of file +
\ No newline at end of file diff --git a/test/validator/samples/await-component-is-used/input.html b/test/validator/samples/await-component-is-used/input.html index f27202d6ddd6..17f2d04d365f 100644 --- a/test/validator/samples/await-component-is-used/input.html +++ b/test/validator/samples/await-component-is-used/input.html @@ -1,10 +1,10 @@ -{{#await promise}} +{#await promise}

Loading

-{{then data}} - -{{catch err}} -

Error: {{err}}

-{{/await}} +{:then data} + +{:catch err} +

Error: {err}

+{/await} diff --git a/test/validator/samples/properties-computed-must-be-valid-function-names/errors.json b/test/validator/samples/properties-computed-must-be-valid-function-names/errors.json index 7cdc2df451a7..8759767afd69 100644 --- a/test/validator/samples/properties-computed-must-be-valid-function-names/errors.json +++ b/test/validator/samples/properties-computed-must-be-valid-function-names/errors.json @@ -7,7 +7,7 @@ }, "end": { "line": 9, - "column": 28 + "column": 16 }, "pos": 87 }] diff --git a/test/validator/samples/properties-computed-must-be-valid-function-names/input.html b/test/validator/samples/properties-computed-must-be-valid-function-names/input.html index 1c9173f52320..35e2c598e00c 100644 --- a/test/validator/samples/properties-computed-must-be-valid-function-names/input.html +++ b/test/validator/samples/properties-computed-must-be-valid-function-names/input.html @@ -6,7 +6,7 @@ }; }, computed: { - "with-hyphen": a => a * 2 + "with-hyphen": ({ a }) => a * 2 } }; diff --git a/test/validator/samples/properties-computed-no-destructuring/errors.json b/test/validator/samples/properties-computed-no-destructuring/errors.json deleted file mode 100644 index 7ac9e009d64e..000000000000 --- a/test/validator/samples/properties-computed-no-destructuring/errors.json +++ /dev/null @@ -1,13 +0,0 @@ -[{ - "code": "invalid-computed-arguments", - "message": "Computed properties cannot use destructuring in function parameters", - "loc": { - "line": 6, - "column": 8 - }, - "end": { - "line": 6, - "column": 16 - }, - "pos": 62 -}] diff --git a/test/validator/samples/properties-computed-no-destructuring/input.html b/test/validator/samples/properties-computed-no-destructuring/input.html deleted file mode 100644 index ae88d47b9e01..000000000000 --- a/test/validator/samples/properties-computed-no-destructuring/input.html +++ /dev/null @@ -1,9 +0,0 @@ -
- - diff --git a/test/validator/samples/store-unexpected/input.html b/test/validator/samples/store-unexpected/input.html deleted file mode 100644 index 589f28e647e0..000000000000 --- a/test/validator/samples/store-unexpected/input.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/validator/samples/store-unexpected/warnings.json b/test/validator/samples/store-unexpected/warnings.json deleted file mode 100644 index 5e0f69f8e624..000000000000 --- a/test/validator/samples/store-unexpected/warnings.json +++ /dev/null @@ -1,13 +0,0 @@ -[{ - "code": "options-missing-store", - "message": "compile with `store: true` in order to call store methods", - "loc": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 29 - }, - "pos": 18 -}] \ No newline at end of file diff --git a/test/validator/samples/svg-child-component-declared-namespace/input.html b/test/validator/samples/svg-child-component-declared-namespace/input.html index c158d7fdf57e..536f47107ed9 100644 --- a/test/validator/samples/svg-child-component-declared-namespace/input.html +++ b/test/validator/samples/svg-child-component-declared-namespace/input.html @@ -1,4 +1,4 @@ - + diff --git a/test/server-side-rendering/samples/default-data-override/main.html b/test/server-side-rendering/samples/default-data-override/main.html index 36054878558b..1014c2df07e1 100644 --- a/test/server-side-rendering/samples/default-data-override/main.html +++ b/test/server-side-rendering/samples/default-data-override/main.html @@ -1,4 +1,4 @@ -

{{foo}}

+

{foo}

\ No newline at end of file diff --git a/test/validator/samples/missing-component/warnings.json b/test/validator/samples/missing-component/errors.json similarity index 100% rename from test/validator/samples/missing-component/warnings.json rename to test/validator/samples/missing-component/errors.json diff --git a/test/validator/samples/window-binding-invalid-innerwidth/errors.json b/test/validator/samples/window-binding-invalid-innerwidth/errors.json index a91a928c6032..e5bc0c7d34b8 100644 --- a/test/validator/samples/window-binding-invalid-innerwidth/errors.json +++ b/test/validator/samples/window-binding-invalid-innerwidth/errors.json @@ -1,6 +1,6 @@ [{ "code": "invalid-binding", - "message": "'innerwidth' is not a valid binding on <:Window> (did you mean 'innerWidth'?)", + "message": "'innerwidth' is not a valid binding on (did you mean 'innerWidth'?)", "loc": { "line": 1, "column": 15 diff --git a/test/validator/samples/window-binding-invalid-value/errors.json b/test/validator/samples/window-binding-invalid-value/errors.json index 32009552d6f2..49b2fa517fd0 100644 --- a/test/validator/samples/window-binding-invalid-value/errors.json +++ b/test/validator/samples/window-binding-invalid-value/errors.json @@ -1,6 +1,6 @@ [{ "code": "invalid-binding", - "message": "Bindings on <:Window/> must be to top-level properties, e.g. 'baz' rather than 'foo.bar.baz'", + "message": "Bindings on must be to top-level properties, e.g. 'baz' rather than 'foo.bar.baz'", "loc": { "line": 1, "column": 32 diff --git a/test/validator/samples/window-binding-invalid-width/errors.json b/test/validator/samples/window-binding-invalid-width/errors.json index 1ac57e825eb1..c340fe3f7d27 100644 --- a/test/validator/samples/window-binding-invalid-width/errors.json +++ b/test/validator/samples/window-binding-invalid-width/errors.json @@ -1,6 +1,6 @@ [{ "code": "invalid-binding", - "message": "'width' is not a valid binding on <:Window> (did you mean 'innerWidth'?)", + "message": "'width' is not a valid binding on (did you mean 'innerWidth'?)", "loc": { "line": 1, "column": 15 diff --git a/test/validator/samples/window-binding-invalid/errors.json b/test/validator/samples/window-binding-invalid/errors.json index 9bebff624df1..7d5f049b7913 100644 --- a/test/validator/samples/window-binding-invalid/errors.json +++ b/test/validator/samples/window-binding-invalid/errors.json @@ -1,6 +1,6 @@ [{ "code": "invalid-binding", - "message": "'potato' is not a valid binding on <:Window> — valid bindings are innerWidth, innerHeight, outerWidth, outerHeight, scrollX, scrollY or online", + "message": "'potato' is not a valid binding on — valid bindings are innerWidth, innerHeight, outerWidth, outerHeight, scrollX, scrollY or online", "loc": { "line": 1, "column": 15 From 73e83e55719d053ad26bf6c2c028bf67f80f966f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 16 Apr 2018 00:05:51 -0400 Subject: [PATCH 26/40] tidy up --- test/helpers.js | 3 +-- test/js/index.js | 3 +-- test/parser/index.js | 2 -- test/runtime/index.js | 1 - test/runtime/samples/store-nested/_config.js | 2 -- test/runtime/samples/store-root/_config.js | 2 -- test/validator/index.js | 3 +-- 7 files changed, 3 insertions(+), 13 deletions(-) diff --git a/test/helpers.js b/test/helpers.js index 2b84764c62e6..0f0a1fd4aefd 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -187,8 +187,7 @@ export function showOutput(cwd, options = {}, compile = svelte.compile) { fs.readFileSync(`${cwd}/${file}`, 'utf-8'), Object.assign(options, { filename: file, - name: capitalise(name), - parser: 'v2' // TODO remove + name: capitalise(name) }) ); diff --git a/test/js/index.js b/test/js/index.js index 00ef3ead9783..1d6e49967920 100644 --- a/test/js/index.js +++ b/test/js/index.js @@ -25,8 +25,7 @@ describe("js", () => { try { const options = Object.assign(config.options || {}, { - shared: true, - parser: 'v2' // TODO remove + shared: true }); actual = svelte.compile(input, options).js.code.replace(/generated by Svelte v\d+\.\d+\.\d+/, 'generated by Svelte vX.Y.Z'); diff --git a/test/parser/index.js b/test/parser/index.js index c32c00af25c3..f2acd631d95e 100644 --- a/test/parser/index.js +++ b/test/parser/index.js @@ -18,8 +18,6 @@ describe('parse', () => { (solo ? it.only : it)(dir, () => { const options = tryToLoadJson(`test/parser/samples/${dir}/options.json`) || {}; - options.parser = 'v2'; // TODO remove - const input = fs.readFileSync(`test/parser/samples/${dir}/input.html`, 'utf-8').replace(/\s+$/, ''); const expectedOutput = tryToLoadJson(`test/parser/samples/${dir}/output.json`); const expectedError = tryToLoadJson(`test/parser/samples/${dir}/error.json`); diff --git a/test/runtime/index.js b/test/runtime/index.js index 109615f30941..199a9a0c9ba0 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -72,7 +72,6 @@ describe("runtime", () => { compileOptions.dev = config.dev; compileOptions.store = !!config.store; compileOptions.immutable = config.immutable; - compileOptions.parser = 'v2'; // TODO remove Object.keys(require.cache) .filter(x => x.endsWith(".html")) diff --git a/test/runtime/samples/store-nested/_config.js b/test/runtime/samples/store-nested/_config.js index bad5ddeffb3b..594bd65873c0 100644 --- a/test/runtime/samples/store-nested/_config.js +++ b/test/runtime/samples/store-nested/_config.js @@ -1,6 +1,4 @@ export default { - store: true, // TODO remove this in v2 - html: `

Hello, world!

`, diff --git a/test/runtime/samples/store-root/_config.js b/test/runtime/samples/store-root/_config.js index 72658d0038ce..278cbff30b38 100644 --- a/test/runtime/samples/store-root/_config.js +++ b/test/runtime/samples/store-root/_config.js @@ -1,6 +1,4 @@ export default { - store: true, // TODO remove this in v2 - html: `

Hello world!

It's nice to see you, world.

diff --git a/test/validator/index.js b/test/validator/index.js index 72231f4a848d..ce89833b7cfe 100644 --- a/test/validator/index.js +++ b/test/validator/index.js @@ -32,8 +32,7 @@ describe("validate", () => { warnings.push({ code, message, pos, loc, end }); }, dev: config.dev, - generate: false, - parser: 'v2' // TODO remove + generate: false }); assert.equal(stats.warnings.length, warnings.length); From dadf21c6b75a88f6f4f0ffa2342903ea683e56c6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 16 Apr 2018 11:41:38 -0400 Subject: [PATCH 27/40] skip test, fix post-v2 --- test/runtime/samples/flush-before-bindings/_config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/runtime/samples/flush-before-bindings/_config.js b/test/runtime/samples/flush-before-bindings/_config.js index 066f3cb2c4c0..5f1e3d21f8eb 100644 --- a/test/runtime/samples/flush-before-bindings/_config.js +++ b/test/runtime/samples/flush-before-bindings/_config.js @@ -1,6 +1,8 @@ // import counter from './counter.js'; export default { + skip: true, // TODO + 'skip-ssr': true, html: ` From d2a5b366d84fe1e01fc6f95d1bb93290436a55c4 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 16 Apr 2018 11:41:48 -0400 Subject: [PATCH 28/40] remove redundant test --- test/runtime/samples/component-data-static/_config.js | 7 ++++++- .../samples/component-data-static/Widget.html | 2 -- .../samples/component-data-static/_actual.html | 4 ---- .../samples/component-data-static/_expected.html | 2 -- .../samples/component-data-static/main.html | 11 ----------- 5 files changed, 6 insertions(+), 20 deletions(-) delete mode 100644 test/server-side-rendering/samples/component-data-static/Widget.html delete mode 100644 test/server-side-rendering/samples/component-data-static/_actual.html delete mode 100644 test/server-side-rendering/samples/component-data-static/_expected.html delete mode 100644 test/server-side-rendering/samples/component-data-static/main.html diff --git a/test/runtime/samples/component-data-static/_config.js b/test/runtime/samples/component-data-static/_config.js index 21ccb131727d..13549b4076ea 100644 --- a/test/runtime/samples/component-data-static/_config.js +++ b/test/runtime/samples/component-data-static/_config.js @@ -1,3 +1,8 @@ export default { - html: '

foo: bar

\n

baz: 42 (number)

' + html: ` +
+

foo: bar

+

baz: 42 (number)

+
+ ` }; diff --git a/test/server-side-rendering/samples/component-data-static/Widget.html b/test/server-side-rendering/samples/component-data-static/Widget.html deleted file mode 100644 index 69fc156eab9f..000000000000 --- a/test/server-side-rendering/samples/component-data-static/Widget.html +++ /dev/null @@ -1,2 +0,0 @@ -

foo: {foo}

-

baz: {baz} ({typeof baz})

diff --git a/test/server-side-rendering/samples/component-data-static/_actual.html b/test/server-side-rendering/samples/component-data-static/_actual.html deleted file mode 100644 index 609215404e5e..000000000000 --- a/test/server-side-rendering/samples/component-data-static/_actual.html +++ /dev/null @@ -1,4 +0,0 @@ -
-

foo: bar

-

baz: 42 (string)

-
\ No newline at end of file diff --git a/test/server-side-rendering/samples/component-data-static/_expected.html b/test/server-side-rendering/samples/component-data-static/_expected.html deleted file mode 100644 index 7e3d0496bd5f..000000000000 --- a/test/server-side-rendering/samples/component-data-static/_expected.html +++ /dev/null @@ -1,2 +0,0 @@ -

foo: bar

-

baz: 42 (number)

diff --git a/test/server-side-rendering/samples/component-data-static/main.html b/test/server-side-rendering/samples/component-data-static/main.html deleted file mode 100644 index 0df72c1465b9..000000000000 --- a/test/server-side-rendering/samples/component-data-static/main.html +++ /dev/null @@ -1,11 +0,0 @@ -
- -
- - From 7e733d82e7cad428b038c5da83d33acd6a905128 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 16 Apr 2018 20:41:31 -0400 Subject: [PATCH 29/40] enforce uppercase component names --- src/validate/js/propValidators/components.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/validate/js/propValidators/components.ts b/src/validate/js/propValidators/components.ts index 10a528b53b72..758b84e86fbf 100644 --- a/src/validate/js/propValidators/components.ts +++ b/src/validate/js/propValidators/components.ts @@ -27,9 +27,9 @@ export default function components(validator: Validator, prop: Node) { } if (!/^[A-Z]/.test(name)) { - validator.warn(component, { + validator.error(component, { code: `component-lowercase`, - message: `Component names should be capitalised` + message: `Component names must be capitalised` }); } }); From b9fcc16d682085d08c2de3ef8ed2bb2f19c4a6ab Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 16 Apr 2018 20:53:17 -0400 Subject: [PATCH 30/40] update test --- .../errors.json} | 2 +- .../input.html | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename test/validator/samples/{properties-components-should-be-capitalised/warnings.json => properties-components-must-be-capitalised/errors.json} (71%) rename test/validator/samples/{properties-components-should-be-capitalised => properties-components-must-be-capitalised}/input.html (100%) diff --git a/test/validator/samples/properties-components-should-be-capitalised/warnings.json b/test/validator/samples/properties-components-must-be-capitalised/errors.json similarity index 71% rename from test/validator/samples/properties-components-should-be-capitalised/warnings.json rename to test/validator/samples/properties-components-must-be-capitalised/errors.json index c1ca7a425cda..c171254888d5 100644 --- a/test/validator/samples/properties-components-should-be-capitalised/warnings.json +++ b/test/validator/samples/properties-components-must-be-capitalised/errors.json @@ -1,6 +1,6 @@ [{ "code": "component-lowercase", - "message": "Component names should be capitalised", + "message": "Component names must be capitalised", "loc": { "line": 6, "column": 3 diff --git a/test/validator/samples/properties-components-should-be-capitalised/input.html b/test/validator/samples/properties-components-must-be-capitalised/input.html similarity index 100% rename from test/validator/samples/properties-components-should-be-capitalised/input.html rename to test/validator/samples/properties-components-must-be-capitalised/input.html From 07bad96719c0154ba32c8dbcfed26fa7f8ffb20e Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 16 Apr 2018 20:53:23 -0400 Subject: [PATCH 31/40] tidy up --- src/generators/Generator.ts | 4 ++-- src/generators/nodes/Component.ts | 8 ++++---- .../server-side-rendering/visitors/Component.ts | 4 ++-- src/parse/state/tag.ts | 10 +--------- src/validate/html/index.ts | 2 -- src/validate/html/validateElement.ts | 2 +- 6 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/generators/Generator.ts b/src/generators/Generator.ts index 68c721fb2a3b..714945fba2b5 100644 --- a/src/generators/Generator.ts +++ b/src/generators/Generator.ts @@ -777,7 +777,7 @@ export default class Generator { node.generator = generator; - if (node.type === 'Element' && (node.name === ':Component' || node.name === ':Self' || node.name === 'svelte:component' || node.name === 'svelte:self' || generator.components.has(node.name))) { + if (node.type === 'Element' && (node.name === 'svelte:component' || node.name === 'svelte:self' || generator.components.has(node.name))) { node.type = 'Component'; Object.setPrototypeOf(node, nodes.Component.prototype); } else if (node.type === 'Element' && node.name === 'title' && parentIsHead(parent)) { // TODO do this in parse? @@ -861,7 +861,7 @@ export default class Generator { this.skip(); } - if (node.type === 'Component' && (node.name === ':Component' || node.name === 'svelte:component')) { + if (node.type === 'Component' && node.name === 'svelte:component') { node.metadata = contextualise(node.expression, contextDependencies, indexes, false); } diff --git a/src/generators/nodes/Component.ts b/src/generators/nodes/Component.ts index fb881ef40e42..7adacc9d0ea0 100644 --- a/src/generators/nodes/Component.ts +++ b/src/generators/nodes/Component.ts @@ -45,8 +45,8 @@ export default class Component extends Node { this.var = block.getUniqueName( ( - (this.name === ':Self' || this.name === 'svelte:self') ? this.generator.name : - (this.name === ':Component' || this.name === 'svelte:component') ? 'switch_instance' : + this.name === 'svelte:self' ? this.generator.name : + this.name === 'svelte:component' ? 'switch_instance' : this.name ).toLowerCase() ); @@ -293,7 +293,7 @@ export default class Component extends Node { `; } - if (this.name === ':Component' || this.name === 'svelte:component') { + if (this.name === 'svelte:component') { const switch_value = block.getUniqueName('switch_value'); const switch_props = block.getUniqueName('switch_props'); @@ -387,7 +387,7 @@ export default class Component extends Node { block.builders.destroy.addLine(`if (${name}) ${name}.destroy(false);`); } else { - const expression = (this.name === ':Self' || this.name === 'svelte:self') + const expression = this.name === 'svelte:self' ? generator.name : `%components-${this.name}`; diff --git a/src/generators/server-side-rendering/visitors/Component.ts b/src/generators/server-side-rendering/visitors/Component.ts index c31ddd917f50..7ff696998393 100644 --- a/src/generators/server-side-rendering/visitors/Component.ts +++ b/src/generators/server-side-rendering/visitors/Component.ts @@ -87,11 +87,11 @@ export default function visitComponent( .concat(bindingProps) .join(', ')} }`; - const isDynamicComponent = node.name === ':Component' || node.name === 'svelte:component'; + const isDynamicComponent = node.name === 'svelte:component'; if (isDynamicComponent) block.contextualise(node.expression); const expression = ( - (node.name === ':Self' || node.name === 'svelte:self') ? generator.name : + node.name === 'svelte:self' ? generator.name : isDynamicComponent ? `((${node.metadata.snippet}) || __missingComponent)` : `%components-${node.name}` ); diff --git a/src/parse/state/tag.ts b/src/parse/state/tag.ts index e1f6af0ad49a..cf0267c2402f 100644 --- a/src/parse/state/tag.ts +++ b/src/parse/state/tag.ts @@ -86,7 +86,7 @@ export default function tag(parser: Parser) { if (metaTags.has(name)) { const slug = metaTags.get(name).toLowerCase(); if (isClosingTag) { - if ((name === ':Window' || name === 'svelte:window') && parser.current().children.length) { + if (name === 'svelte:window' && parser.current().children.length) { parser.error({ code: `invalid-window-content`, message: `<${name}> cannot have children` @@ -176,14 +176,6 @@ export default function tag(parser: Parser) { } } - if (name === ':Component') { - parser.eat('{', true); - element.expression = readExpression(parser); - parser.allowWhitespace(); - parser.eat('}', true); - parser.allowWhitespace(); - } - const uniqueNames = new Set(); let attribute; diff --git a/src/validate/html/index.ts b/src/validate/html/index.ts index f543ebd27e63..e471ff6b4135 100644 --- a/src/validate/html/index.ts +++ b/src/validate/html/index.ts @@ -31,8 +31,6 @@ export default function validateHtml(validator: Validator, html: Node) { else if (node.type === 'Element') { const isComponent = - node.name === ':Self' || - node.name === ':Component' || node.name === 'svelte:self' || node.name === 'svelte:component' || validator.components.has(node.name); diff --git a/src/validate/html/validateElement.ts b/src/validate/html/validateElement.ts index 078f3f64587c..2a327697971a 100644 --- a/src/validate/html/validateElement.ts +++ b/src/validate/html/validateElement.ts @@ -297,7 +297,7 @@ function checkSlotAttribute(validator: Validator, node: Node, attribute: Node, s const parent = stack[i]; if (parent.type === 'Element') { // if we're inside a component or a custom element, gravy - if (parent.name === ':Self' || parent.name === ':Component' || parent.name === 'svelte:self' || parent.name === 'svelte:component' || validator.components.has(parent.name)) return; + if (parent.name === 'svelte:self' || parent.name === 'svelte:component' || validator.components.has(parent.name)) return; if (/-/.test(parent.name)) return; } From 5a457bfb878dd1784e6b832f730d39c3013941df Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 16 Apr 2018 21:50:57 -0400 Subject: [PATCH 32/40] rename loc to start, include character info in locations --- package.json | 2 +- src/css/Stylesheet.ts | 12 ++-- src/generators/Generator.ts | 1 - src/index.ts | 4 +- src/interfaces.ts | 2 +- src/parse/index.ts | 1 - src/utils/error.ts | 14 ++-- src/validate/index.ts | 8 +-- test/css/samples/empty-class/_config.js | 10 ++- .../_config.js | 10 ++- test/css/samples/refs-qualified/_config.js | 10 ++- test/css/samples/refs/_config.js | 10 ++- .../unused-selector-leading/_config.js | 20 ++++-- .../unused-selector-ternary/_config.js | 10 ++- test/css/samples/unused-selector/_config.js | 10 ++- test/js/index.js | 2 +- test/parser/index.js | 4 +- .../samples/attribute-unique-error/error.json | 5 +- .../samples/error-binding-disabled/error.json | 5 +- .../error-binding-mustaches/error.json | 5 +- .../samples/error-binding-rvalue/error.json | 5 +- .../samples/error-comment-unclosed/error.json | 5 +- test/parser/samples/error-css/error.json | 5 +- .../samples/error-event-handler/error.json | 5 +- .../error-illegal-expression/error.json | 5 +- .../samples/error-multiple-styles/error.json | 5 +- .../parser/samples/error-ref-value/error.json | 5 +- .../samples/error-script-unclosed/error.json | 5 +- .../samples/error-self-reference/error.json | 5 +- .../error.json | 5 +- .../error.json | 5 +- .../error.json | 5 +- .../error-unexpected-end-of-input/error.json | 5 +- .../error-unmatched-closing-tag/error.json | 5 +- .../samples/error-void-closing/error.json | 5 +- .../samples/error-window-children/error.json | 5 +- .../samples/error-window-duplicate/error.json | 5 +- .../error-window-inside-block/error.json | 5 +- .../error-window-inside-element/error.json | 5 +- test/sourcemaps/samples/basic/test.js | 14 ++-- .../samples/binding-shorthand/test.js | 12 ++-- test/sourcemaps/samples/binding/test.js | 14 ++-- test/sourcemaps/samples/css/test.js | 6 +- test/sourcemaps/samples/each-block/test.js | 6 +- test/sourcemaps/samples/script/test.js | 6 +- test/stats/index.js | 2 +- test/validator/index.js | 14 ++-- .../samples/a11y-alt-text/warnings.json | 32 +++++---- .../a11y-anchor-has-content/warnings.json | 8 ++- .../a11y-anchor-in-svg-is-valid/warnings.json | 66 ++++++++++--------- .../a11y-anchor-is-valid/warnings.json | 24 ++++--- .../samples/a11y-aria-props/warnings.json | 16 +++-- .../samples/a11y-aria-role/warnings.json | 8 ++- .../warnings.json | 16 +++-- .../a11y-figcaption-wrong-place/warnings.json | 16 +++-- .../a11y-heading-has-content/warnings.json | 16 +++-- .../samples/a11y-html-has-lang/warnings.json | 8 ++- .../a11y-iframe-has-title/warnings.json | 8 ++- .../samples/a11y-no-access-key/warnings.json | 8 ++- .../samples/a11y-no-autofocus/warnings.json | 8 ++- .../warnings.json | 16 +++-- .../a11y-not-on-components/warnings.json | 8 ++- .../samples/a11y-scope/warnings.json | 8 ++- .../a11y-tabindex-no-positive/warnings.json | 8 ++- .../samples/action-invalid/errors.json | 8 ++- .../samples/action-on-component/errors.json | 8 ++- .../samples/binding-input-checked/errors.json | 8 ++- .../binding-input-type-boolean/errors.json | 8 ++- .../binding-input-type-dynamic/errors.json | 8 ++- .../binding-invalid-on-element/errors.json | 8 ++- .../samples/binding-invalid/errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 2 +- .../errors.json | 8 ++- .../errors.json | 8 ++- .../component-slot-dynamic/errors.json | 8 ++- .../component-slot-each-block/errors.json | 8 ++- .../errors.json | 2 +- .../component-slotted-each-block/errors.json | 8 ++- .../component-slotted-if-block/errors.json | 8 ++- .../computed-purity-check-no-this/errors.json | 8 ++- .../errors.json | 8 ++- .../css-invalid-global-placement/errors.json | 8 ++- .../samples/css-invalid-global/errors.json | 8 ++- .../errors.json | 8 ++- .../each-block-invalid-context/errors.json | 8 ++- .../samples/empty-block-dev/warnings.json | 16 +++-- .../event-handler-ref-invalid/errors.json | 8 ++- .../export-default-duplicated/errors.json | 8 ++- .../export-default-must-be-object/errors.json | 8 ++- .../helper-clash-context/warnings.json | 8 ++- .../warnings.json | 8 ++- .../helper-purity-check-no-this/errors.json | 8 ++- .../helper-purity-check-this-get/errors.json | 8 ++- .../samples/method-arrow-this/errors.json | 8 ++- .../method-nonexistent-helper/warnings.json | 8 ++- .../samples/method-nonexistent/warnings.json | 8 ++- .../samples/missing-component/errors.json | 8 ++- .../samples/named-export/errors.json | 8 ++- .../namespace-invalid-unguessable/errors.json | 8 ++- .../samples/namespace-invalid/errors.json | 8 ++- .../samples/namespace-non-literal/errors.json | 8 ++- .../non-object-literal-components/errors.json | 8 ++- .../non-object-literal-events/errors.json | 8 ++- .../non-object-literal-helpers/errors.json | 8 ++- .../non-object-literal-methods/errors.json | 8 ++- .../errors.json | 8 ++- .../samples/oncreate-arrow-this/errors.json | 8 ++- .../samples/ondestroy-arrow-this/errors.json | 8 ++- .../samples/onstate-arrow-this/errors.json | 8 ++- .../samples/onupdate-arrow-this/errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 8 ++- .../samples/properties-duplicated/errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 8 ++- .../properties-unexpected-b/errors.json | 8 ++- .../samples/properties-unexpected/errors.json | 8 ++- .../slot-attribute-invalid/errors.json | 8 ++- .../warnings.json | 8 ++- .../validator/samples/tag-invalid/errors.json | 8 ++- .../samples/tag-non-string/errors.json | 8 ++- .../textarea-value-children/errors.json | 8 ++- .../samples/title-no-attributes/errors.json | 8 ++- .../samples/title-no-children/errors.json | 8 ++- .../errors.json | 8 ++- .../transition-duplicate-in/errors.json | 8 ++- .../errors.json | 8 ++- .../transition-duplicate-out/errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 8 ++- .../errors.json | 8 ++- .../samples/transition-missing/errors.json | 8 ++- .../transition-on-component/errors.json | 8 ++- .../samples/unused-components/warnings.json | 16 +++-- .../samples/unused-event/warnings.json | 8 ++- .../samples/unused-helper.skip/warnings.json | 2 +- .../samples/unused-transition/warnings.json | 8 ++- .../errors.json | 8 ++- .../window-binding-invalid-value/errors.json | 8 ++- .../window-binding-invalid-width/errors.json | 8 ++- .../window-binding-invalid/errors.json | 8 ++- .../window-event-invalid/warnings.json | 8 ++- yarn.lock | 2 +- 151 files changed, 787 insertions(+), 489 deletions(-) diff --git a/package.json b/package.json index ae3df5b31bd0..89229e313085 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "glob": "^7.1.1", "is-reference": "^1.1.0", "jsdom": "^11.6.1", - "locate-character": "^2.0.0", + "locate-character": "^2.0.5", "magic-string": "^0.22.3", "mocha": "^3.2.0", "nightmare": "^2.10.0", diff --git a/src/css/Stylesheet.ts b/src/css/Stylesheet.ts index 3f5262fcc13a..4a3630f30044 100644 --- a/src/css/Stylesheet.ts +++ b/src/css/Stylesheet.ts @@ -392,20 +392,22 @@ export default class Stylesheet { const handler = (selector: Selector) => { const pos = selector.node.start; - if (!locator) locator = getLocator(this.source); - const { line, column } = locator(pos); + if (!locator) locator = getLocator(this.source, { offsetLine: 1 }); + const start = locator(pos); + const end = locator(selector.node.end); - const frame = getCodeFrame(this.source, line, column); + const frame = getCodeFrame(this.source, start.line - 1, start.column); const message = `Unused CSS selector`; onwarn({ code: `css-unused-selector`, message, frame, - loc: { line: line + 1, column }, + start, + end, pos, filename: this.filename, - toString: () => `${message} (${line + 1}:${column})\n${frame}`, + toString: () => `${message} (${start.line}:${start.column})\n${frame}`, }); }; diff --git a/src/generators/Generator.ts b/src/generators/Generator.ts index 714945fba2b5..5bbf2e17f1c0 100644 --- a/src/generators/Generator.ts +++ b/src/generators/Generator.ts @@ -5,7 +5,6 @@ import { getLocator } from 'locate-character'; import Stats from '../Stats'; import deindent from '../utils/deindent'; import CodeBuilder from '../utils/CodeBuilder'; -import getCodeFrame from '../utils/getCodeFrame'; import flattenReference from '../utils/flattenReference'; import reservedNames from '../utils/reservedNames'; import namespaces from '../utils/namespaces'; diff --git a/src/index.ts b/src/index.ts index 875202118bdc..6178b1e45f05 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,9 +23,9 @@ function normalizeOptions(options: CompileOptions): CompileOptions { } function defaultOnwarn(warning: Warning) { - if (warning.loc) { + if (warning.start) { console.warn( - `(${warning.loc.line}:${warning.loc.column}) – ${warning.message}` + `(${warning.start.line}:${warning.start.column}) – ${warning.message}` ); // eslint-disable-line no-console } else { console.warn(warning.message); // eslint-disable-line no-console diff --git a/src/interfaces.ts b/src/interfaces.ts index 6ed7e31dded0..c49ea0494f0b 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -28,7 +28,7 @@ export interface Parsed { } export interface Warning { - loc?: { line: number; column: number; pos?: number }; + start?: { line: number; column: number; pos?: number }; end?: { line: number; column: number; }; pos?: number; code: string; diff --git a/src/parse/index.ts b/src/parse/index.ts index f3d724c84780..1ea91e040b59 100644 --- a/src/parse/index.ts +++ b/src/parse/index.ts @@ -3,7 +3,6 @@ import { locate, Location } from 'locate-character'; import fragment from './state/fragment'; import { whitespace } from '../utils/patterns'; import { trimStart, trimEnd } from '../utils/trim'; -import getCodeFrame from '../utils/getCodeFrame'; import reservedNames from '../utils/reservedNames'; import fullCharCodeAt from '../utils/fullCharCodeAt'; import hash from '../utils/hash'; diff --git a/src/utils/error.ts b/src/utils/error.ts index 35daba2c80b0..acaab3711719 100644 --- a/src/utils/error.ts +++ b/src/utils/error.ts @@ -3,14 +3,14 @@ import getCodeFrame from '../utils/getCodeFrame'; class CompileError extends Error { code: string; - loc: { line: number, column: number }; + start: { line: number, column: number }; end: { line: number, column: number }; pos: number; filename: string; frame: string; toString() { - return `${this.message} (${this.loc.line}:${this.loc.column})\n${this.frame}`; + return `${this.message} (${this.start.line}:${this.start.column})\n${this.frame}`; } } @@ -25,16 +25,16 @@ export default function error(message: string, props: { const error = new CompileError(message); error.name = props.name; - const start = locate(props.source, props.start); - const end = locate(props.source, props.end || props.start); + const start = locate(props.source, props.start, { offsetLine: 1 }); + const end = locate(props.source, props.end || props.start, { offsetLine: 1 }); error.code = props.code; - error.loc = { line: start.line + 1, column: start.column }; - error.end = { line: end.line + 1, column: end.column }; + error.start = start; + error.end = end; error.pos = props.start; error.filename = props.filename; - error.frame = getCodeFrame(props.source, start.line, start.column); + error.frame = getCodeFrame(props.source, start.line - 1, start.column); throw error; } \ No newline at end of file diff --git a/src/validate/index.ts b/src/validate/index.ts index 9734124d2633..b79a93a0cebc 100644 --- a/src/validate/index.ts +++ b/src/validate/index.ts @@ -73,18 +73,18 @@ export class Validator { } warn(pos: { start: number, end: number }, { code, message }: { code: string, message: string }) { - if (!this.locator) this.locator = getLocator(this.source); + if (!this.locator) this.locator = getLocator(this.source, { offsetLine: 1 }); const start = this.locator(pos.start); const end = this.locator(pos.end); - const frame = getCodeFrame(this.source, start.line, start.column); + const frame = getCodeFrame(this.source, start.line - 1, start.column); this.stats.warn({ code, message, frame, - loc: { line: start.line + 1, column: start.column }, - end: { line: end.line + 1, column: end.column }, + start, + end, pos: pos.start, filename: this.filename, toString: () => `${message} (${start.line + 1}:${start.column})\n${frame}`, diff --git a/test/css/samples/empty-class/_config.js b/test/css/samples/empty-class/_config.js index 5ffb0321bb71..fb1565c7bc39 100644 --- a/test/css/samples/empty-class/_config.js +++ b/test/css/samples/empty-class/_config.js @@ -3,9 +3,15 @@ export default { filename: "SvelteComponent.html", code: `css-unused-selector`, message: "Unused CSS selector", - loc: { + start: { line: 4, - column: 1 + column: 1, + character: 31 + }, + end: { + line: 4, + column: 3, + character: 33 }, pos: 31, frame: ` diff --git a/test/css/samples/omit-scoping-attribute-descendant/_config.js b/test/css/samples/omit-scoping-attribute-descendant/_config.js index 1fb3055ae105..a4aaec7c19d5 100644 --- a/test/css/samples/omit-scoping-attribute-descendant/_config.js +++ b/test/css/samples/omit-scoping-attribute-descendant/_config.js @@ -2,9 +2,15 @@ export default { warnings: [{ code: `css-unused-selector`, message: 'Unused CSS selector', - loc: { + start: { line: 8, - column: 1 + column: 1, + character: 74 + }, + end: { + line: 8, + column: 8, + character: 81 }, pos: 74, frame: ` diff --git a/test/css/samples/refs-qualified/_config.js b/test/css/samples/refs-qualified/_config.js index 9f75d743ccde..dbc3ac2b4ef1 100644 --- a/test/css/samples/refs-qualified/_config.js +++ b/test/css/samples/refs-qualified/_config.js @@ -6,9 +6,15 @@ export default { warnings: [{ code: `css-unused-selector`, message: 'Unused CSS selector', - loc: { + start: { column: 1, - line: 12 + line: 12, + character: 169 + }, + end: { + column: 20, + line: 12, + character: 188 }, pos: 169, frame: ` diff --git a/test/css/samples/refs/_config.js b/test/css/samples/refs/_config.js index 4c684d76e596..76252a8a5fa2 100644 --- a/test/css/samples/refs/_config.js +++ b/test/css/samples/refs/_config.js @@ -2,9 +2,15 @@ export default { warnings: [{ code: `css-unused-selector`, message: 'Unused CSS selector', - loc: { + start: { column: 1, - line: 14 + line: 14, + character: 120 + }, + end: { + column: 6, + line: 14, + character: 125 }, pos: 120, frame: ` diff --git a/test/css/samples/unused-selector-leading/_config.js b/test/css/samples/unused-selector-leading/_config.js index ec245fe80ae3..c01e978405dc 100644 --- a/test/css/samples/unused-selector-leading/_config.js +++ b/test/css/samples/unused-selector-leading/_config.js @@ -4,9 +4,15 @@ export default { filename: "SvelteComponent.html", code: `css-unused-selector`, message: "Unused CSS selector", - loc: { + start: { line: 4, - column: 1 + column: 1, + character: 34 + }, + end: { + line: 4, + column: 5, + character: 38 }, pos: 34, frame: ` @@ -22,9 +28,15 @@ export default { filename: "SvelteComponent.html", code: `css-unused-selector`, message: "Unused CSS selector", - loc: { + start: { + line: 4, + column: 13, + character: 46 + }, + end: { line: 4, - column: 13 + column: 17, + character: 50 }, pos: 46, frame: ` diff --git a/test/css/samples/unused-selector-ternary/_config.js b/test/css/samples/unused-selector-ternary/_config.js index f4f7826ffc44..f99ad90601ad 100644 --- a/test/css/samples/unused-selector-ternary/_config.js +++ b/test/css/samples/unused-selector-ternary/_config.js @@ -7,9 +7,15 @@ export default { filename: "SvelteComponent.html", code: `css-unused-selector`, message: "Unused CSS selector", - loc: { + start: { line: 12, - column: 1 + column: 1, + character: 123 + }, + end: { + line: 12, + column: 13, + character: 135 }, pos: 123, frame: ` diff --git a/test/css/samples/unused-selector/_config.js b/test/css/samples/unused-selector/_config.js index 23f4f757715b..5f6abbc08b7e 100644 --- a/test/css/samples/unused-selector/_config.js +++ b/test/css/samples/unused-selector/_config.js @@ -3,9 +3,15 @@ export default { filename: "SvelteComponent.html", code: `css-unused-selector`, message: "Unused CSS selector", - loc: { + start: { line: 8, - column: 1 + column: 1, + character: 60 + }, + end: { + line: 8, + column: 5, + character: 64 }, pos: 60, frame: ` diff --git a/test/js/index.js b/test/js/index.js index 1d6e49967920..8c6104fa37d2 100644 --- a/test/js/index.js +++ b/test/js/index.js @@ -71,7 +71,7 @@ describe("js", () => { expectedBundle.trim().replace(/^[ \t]+$/gm, "") ); }).catch(err => { - if (err.loc) console.error(err.loc); + if (err.start) console.error(err.start); throw err; }); }); diff --git a/test/parser/index.js b/test/parser/index.js index f2acd631d95e..7a87fc51b1eb 100644 --- a/test/parser/index.js +++ b/test/parser/index.js @@ -37,9 +37,9 @@ describe('parse', () => { try { assert.equal(err.code, expectedError.code); assert.equal(err.message, expectedError.message); - assert.deepEqual(err.loc, expectedError.loc); + assert.deepEqual(err.start, expectedError.start); assert.equal(err.pos, expectedError.pos); - assert.equal(err.toString().split('\n')[0], `${expectedError.message} (${expectedError.loc.line}:${expectedError.loc.column})`); + assert.equal(err.toString().split('\n')[0], `${expectedError.message} (${expectedError.start.line}:${expectedError.start.column})`); } catch (err2) { const e = err2.code === 'MODULE_NOT_FOUND' ? err : err2; throw e; diff --git a/test/parser/samples/attribute-unique-error/error.json b/test/parser/samples/attribute-unique-error/error.json index 737157b24657..dd145721499e 100644 --- a/test/parser/samples/attribute-unique-error/error.json +++ b/test/parser/samples/attribute-unique-error/error.json @@ -1,9 +1,10 @@ { "code": "duplicate-attribute", "message": "Attributes need to be unique", - "loc": { + "start": { "line": 1, - "column": 17 + "column": 17, + "character": 17 }, "pos": 17 } diff --git a/test/parser/samples/error-binding-disabled/error.json b/test/parser/samples/error-binding-disabled/error.json index 71953c41766f..63f01e705694 100644 --- a/test/parser/samples/error-binding-disabled/error.json +++ b/test/parser/samples/error-binding-disabled/error.json @@ -1,9 +1,10 @@ { "code": "binding-disabled", "message": "Two-way binding is disabled", - "loc": { + "start": { "line": 1, - "column": 7 + "column": 7, + "character": 7 }, "pos": 7 } \ No newline at end of file diff --git a/test/parser/samples/error-binding-mustaches/error.json b/test/parser/samples/error-binding-mustaches/error.json index 4d239270860f..b2a5c1c564b1 100644 --- a/test/parser/samples/error-binding-mustaches/error.json +++ b/test/parser/samples/error-binding-mustaches/error.json @@ -1,9 +1,10 @@ { "code": "invalid-directive-value", "message": "directive values should not be wrapped — use 'foo', not '{foo}'", - "loc": { + "start": { "line": 1, - "column": 19 + "column": 19, + "character": 19 }, "pos": 19 } \ No newline at end of file diff --git a/test/parser/samples/error-binding-rvalue/error.json b/test/parser/samples/error-binding-rvalue/error.json index b774b8a29f3c..2d081afac509 100644 --- a/test/parser/samples/error-binding-rvalue/error.json +++ b/test/parser/samples/error-binding-rvalue/error.json @@ -2,8 +2,9 @@ "code": "invalid-directive-value", "message": "Can only bind to an identifier (e.g. `foo`) or a member expression (e.g. `foo.bar` or `foo[baz]`)", "pos": 19, - "loc": { + "start": { "line": 1, - "column": 19 + "column": 19, + "character": 19 } } \ No newline at end of file diff --git a/test/parser/samples/error-comment-unclosed/error.json b/test/parser/samples/error-comment-unclosed/error.json index d83ecbdc0961..8e355fb8211b 100644 --- a/test/parser/samples/error-comment-unclosed/error.json +++ b/test/parser/samples/error-comment-unclosed/error.json @@ -1,9 +1,10 @@ { "code": "unexpected-eof", "message": "comment was left open, expected -->", - "loc": { + "start": { "line": 1, - "column": 24 + "column": 24, + "character": 24 }, "pos": 24 } diff --git a/test/parser/samples/error-css/error.json b/test/parser/samples/error-css/error.json index db6703b3d0d6..90f7a091d2d8 100644 --- a/test/parser/samples/error-css/error.json +++ b/test/parser/samples/error-css/error.json @@ -1,9 +1,10 @@ { "code": "css-syntax-error", "message": "LeftCurlyBracket is expected", - "loc": { + "start": { "line": 2, - "column": 16 + "column": 16, + "character": 24 }, "pos": 24 } diff --git a/test/parser/samples/error-event-handler/error.json b/test/parser/samples/error-event-handler/error.json index 43be6e395120..8ccfa1c881a2 100644 --- a/test/parser/samples/error-event-handler/error.json +++ b/test/parser/samples/error-event-handler/error.json @@ -1,9 +1,10 @@ { "code": "invalid-directive-value", "message": "Expected a method call", - "loc": { + "start": { "line": 1, - "column": 15 + "column": 15, + "character": 15 }, "pos": 15 } \ No newline at end of file diff --git a/test/parser/samples/error-illegal-expression/error.json b/test/parser/samples/error-illegal-expression/error.json index fdce2f1fb942..d8b48a786e7d 100644 --- a/test/parser/samples/error-illegal-expression/error.json +++ b/test/parser/samples/error-illegal-expression/error.json @@ -1,9 +1,10 @@ { "code": "parse-error", "message": "Assigning to rvalue", - "loc": { + "start": { "line": 1, - "column": 1 + "column": 1, + "character": 1 }, "pos": 1 } diff --git a/test/parser/samples/error-multiple-styles/error.json b/test/parser/samples/error-multiple-styles/error.json index 937a37a1f3b8..1c460c5bade2 100644 --- a/test/parser/samples/error-multiple-styles/error.json +++ b/test/parser/samples/error-multiple-styles/error.json @@ -1,9 +1,10 @@ { "code": "duplicate-style", "message": "You can only have one top-level