From e7f448d395a8cec59f1e8ed148394366cc6f785d Mon Sep 17 00:00:00 2001 From: PaulBGD Date: Mon, 5 Mar 2018 17:42:17 -0600 Subject: [PATCH 001/187] Add TypeScript definitions for store (fixes #1207) --- store.d.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 store.d.ts diff --git a/store.d.ts b/store.d.ts new file mode 100644 index 0000000000..db29eaaa2a --- /dev/null +++ b/store.d.ts @@ -0,0 +1,23 @@ +interface Options { + immutable: boolean; +} + +interface ObserveOptions { + defer: boolean; + init: boolean; +} + +interface Cancellable { + cancel: () => void; +} + +export declare class Store { + constructor(state: State, options?: Options); + + public compute(key: string, dependencies: string[]): void; + public get(): State; + public get(key: string): T; + public observe(key: string, callback: (value: T) => any, options?: ObserveOptions): Cancellable; + public onchange(callback: (state: State) => any): Cancellable; + public set(state: State); +} From 62c5f5f8cf59795ea53bd540c620706d01a0476e Mon Sep 17 00:00:00 2001 From: PaulBGD Date: Mon, 5 Mar 2018 17:46:17 -0600 Subject: [PATCH 002/187] Add to files --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 3524d42eb4..702e457388 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "shared.js", "store.js", "store.umd.js", + "store.d.ts", "README.md" ], "scripts": { From 9e9a078d5c58d630affc51091dcdac9f7b7168c1 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 29 Apr 2018 13:02:33 -0400 Subject: [PATCH 003/187] set window scroll from bindings on initialisation - fixes #938 --- src/compile/dom/index.ts | 4 +- src/compile/nodes/Window.ts | 40 ++++++++++++++----- .../computed-collapsed-if/expected-bundle.js | 1 + .../samples/computed-collapsed-if/expected.js | 1 + .../expected-bundle.js | 1 + .../expected.js | 1 + .../window-binding-scroll/expected-bundle.js | 4 ++ .../samples/window-binding-scroll/expected.js | 4 ++ 8 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/compile/dom/index.ts b/src/compile/dom/index.ts index e43d64e3f2..bcf9949ffb 100644 --- a/src/compile/dom/index.ts +++ b/src/compile/dom/index.ts @@ -18,7 +18,7 @@ import { Ast, CompileOptions, Node } from '../../interfaces'; export class DomTarget { blocks: (Block|string)[]; readonly: Set; - metaBindings: string[]; + metaBindings: CodeBuilder; hasIntroTransitions: boolean; hasOutroTransitions: boolean; @@ -29,7 +29,7 @@ export class DomTarget { this.readonly = new Set(); // initial values for e.g. window.innerWidth, if there's a meta tag - this.metaBindings = []; + this.metaBindings = new CodeBuilder(); } } diff --git a/src/compile/nodes/Window.ts b/src/compile/nodes/Window.ts index 6651fce854..31d342a10e 100644 --- a/src/compile/nodes/Window.ts +++ b/src/compile/nodes/Window.ts @@ -121,14 +121,10 @@ export default class Window extends Node { const property = properties[binding.name] || binding.name; if (!events[associatedEvent]) events[associatedEvent] = []; - events[associatedEvent].push( - `${binding.value.node.name}: this.${property}` - ); - - // add initial value - compiler.target.metaBindings.push( - `this._state.${binding.value.node.name} = window.${property};` - ); + events[associatedEvent].push({ + name: binding.value.node.name, + value: property + }); }); const lock = block.getUniqueName(`window_updating`); @@ -137,13 +133,37 @@ export default class Window extends Node { Object.keys(events).forEach(event => { const handlerName = block.getUniqueName(`onwindow${event}`); - const props = events[event].join(',\n'); + const props = events[event]; if (event === 'scroll') { // TODO other bidirectional bindings... block.addVariable(lock, 'false'); block.addVariable(clear, `function() { ${lock} = false; }`); block.addVariable(timeout); + + const condition = [ + bindings.scrollX && `"${bindings.scrollX}" in this._state`, + bindings.scrollY && `"${bindings.scrollY}" in this._state` + ].filter(Boolean).join(' || '); + + const x = bindings.scrollX && `this._state.${bindings.scrollX}`; + const y = bindings.scrollY && `this._state.${bindings.scrollY}`; + + compiler.target.metaBindings.addBlock(deindent` + if (${condition}) { + window.scrollTo(${x || 'window.pageXOffset'}, ${y || 'window.pageYOffset'}); + } + + ${x && `${x} = window.pageXOffset;`} + + ${y && `${y} = window.pageYOffset;`} + `); + } else { + props.forEach(prop => { + compiler.target.metaBindings.addLine( + `this._state.${prop.name} = window.${prop.value};` + ); + }); } const handlerBody = deindent` @@ -154,7 +174,7 @@ export default class Window extends Node { ${compiler.options.dev && `component._updatingReadonlyProperty = true;`} #component.set({ - ${props} + ${props.map(prop => `${prop.name}: this.${prop.value}`)} }); ${compiler.options.dev && `component._updatingReadonlyProperty = false;`} diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 0ea5200f7d..c2a8bb251e 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -149,6 +149,7 @@ function create_main_fragment(component, ctx) { function SvelteComponent(options) { init(this, options); this._state = assign({}, options.data); + this._recompute({ x: 1 }, this._state); this._fragment = create_main_fragment(this, this._state); diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index 5c248bf515..5106a4fd87 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -27,6 +27,7 @@ function create_main_fragment(component, ctx) { function SvelteComponent(options) { init(this, options); this._state = assign({}, options.data); + this._recompute({ x: 1 }, this._state); this._fragment = create_main_fragment(this, this._state); 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 bea4d272db..b942565727 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 @@ -206,6 +206,7 @@ function SvelteComponent(options) { 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'"); 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 93be0ba0c1..a61b8ee01c 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected.js @@ -46,6 +46,7 @@ function SvelteComponent(options) { 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'"); diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index ffc59dacc5..d23cbbf2bd 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -198,6 +198,10 @@ function create_main_fragment(component, ctx) { function SvelteComponent(options) { init(this, options); this._state = assign({}, options.data); + if ("y" in this._state) { + window.scrollTo(window.pageXOffset, this._state.y); + } + this._state.y = window.pageYOffset; this._fragment = create_main_fragment(this, this._state); diff --git a/test/js/samples/window-binding-scroll/expected.js b/test/js/samples/window-binding-scroll/expected.js index d3f6718dd6..800b624875 100644 --- a/test/js/samples/window-binding-scroll/expected.js +++ b/test/js/samples/window-binding-scroll/expected.js @@ -56,6 +56,10 @@ function create_main_fragment(component, ctx) { function SvelteComponent(options) { init(this, options); this._state = assign({}, options.data); + if ("y" in this._state) { + window.scrollTo(window.pageXOffset, this._state.y); + } + this._state.y = window.pageYOffset; this._fragment = create_main_fragment(this, this._state); From e087d08880d286ed8fc140354a18d9c2ee0bbe84 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 6 Jun 2018 18:00:43 -0400 Subject: [PATCH 004/187] failing test for #1522 --- .../samples/onstate-before-render/_config.js | 14 ++++++++++ .../samples/onstate-before-render/main.html | 26 +++++++++++++++++++ .../samples/onstate-before-render/order.js | 1 + 3 files changed, 41 insertions(+) create mode 100644 test/runtime/samples/onstate-before-render/_config.js create mode 100644 test/runtime/samples/onstate-before-render/main.html create mode 100644 test/runtime/samples/onstate-before-render/order.js diff --git a/test/runtime/samples/onstate-before-render/_config.js b/test/runtime/samples/onstate-before-render/_config.js new file mode 100644 index 0000000000..56e30077bd --- /dev/null +++ b/test/runtime/samples/onstate-before-render/_config.js @@ -0,0 +1,14 @@ +import order from './order.js'; + +export default { + 'skip-ssr': true, + + test(assert, component, target) { + assert.deepEqual(order, [ + 'onstate', + 'render', + 'oncreate', + 'onupdate' + ]); + } +}; diff --git a/test/runtime/samples/onstate-before-render/main.html b/test/runtime/samples/onstate-before-render/main.html new file mode 100644 index 0000000000..572275268c --- /dev/null +++ b/test/runtime/samples/onstate-before-render/main.html @@ -0,0 +1,26 @@ +{identity(42)} + + \ No newline at end of file diff --git a/test/runtime/samples/onstate-before-render/order.js b/test/runtime/samples/onstate-before-render/order.js new file mode 100644 index 0000000000..109fa8b38c --- /dev/null +++ b/test/runtime/samples/onstate-before-render/order.js @@ -0,0 +1 @@ +export default []; \ No newline at end of file From aebafcc97568974990aa63bd150dfd27467470c6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 6 Jun 2018 18:03:21 -0400 Subject: [PATCH 005/187] fix for #1522... maybe? --- src/compile/dom/index.ts | 3 ++- test/runtime/samples/onstate-before-render/_config.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compile/dom/index.ts b/src/compile/dom/index.ts index 0a02b664be..6baa397241 100644 --- a/src/compile/dom/index.ts +++ b/src/compile/dom/index.ts @@ -222,11 +222,12 @@ export default function dom( ${compiler.slots.size && `this.slots = {};`} + ${templateProperties.onstate && `%onstate.call(this, { changed: @assignTrue({}, this._state), current: this._state });`} + this._fragment = @create_main_fragment(this, this._state); ${hasInitHooks && deindent` this.root._oncreate.push(() => { - ${templateProperties.onstate && `%onstate.call(this, { changed: @assignTrue({}, this._state), current: this._state });`} ${templateProperties.oncreate && `%oncreate.call(this);`} this.fire("update", { changed: @assignTrue({}, this._state), current: this._state }); }); diff --git a/test/runtime/samples/onstate-before-render/_config.js b/test/runtime/samples/onstate-before-render/_config.js index 56e30077bd..97c3af5083 100644 --- a/test/runtime/samples/onstate-before-render/_config.js +++ b/test/runtime/samples/onstate-before-render/_config.js @@ -10,5 +10,7 @@ export default { 'oncreate', 'onupdate' ]); + + order.length = 0; } }; From 52ece0b5f02e78d1a92b9088bb35ec858745a88d Mon Sep 17 00:00:00 2001 From: Pavel Malyshev Date: Wed, 20 Jun 2018 18:10:48 +0300 Subject: [PATCH 006/187] Fix for #1538 --- src/compile/nodes/Component.ts | 2 +- src/shared/index.js | 2 +- test/cli/samples/basic/expected/Main.js | 2 +- test/cli/samples/custom-element/expected/Main.js | 2 +- test/cli/samples/dev/expected/Main.js | 2 +- test/cli/samples/dir-sourcemap/expected/Main.js | 7 ++++--- test/cli/samples/dir-sourcemap/expected/Main.js.map | 2 +- test/cli/samples/dir-sourcemap/expected/Widget.js | 4 ++-- test/cli/samples/dir-subdir/expected/Main.js | 5 +++-- test/cli/samples/dir-subdir/expected/widget/Widget.js | 2 +- test/cli/samples/dir/expected/Main.js | 5 +++-- test/cli/samples/dir/expected/Widget.js | 2 +- test/cli/samples/globals/expected/Main.js | 2 +- test/cli/samples/sourcemap-inline/expected/Main.js | 2 +- test/cli/samples/sourcemap/expected/Main.js | 2 +- test/cli/samples/store/expected/Main.js | 2 +- test/js/samples/action/expected-bundle.js | 2 +- test/js/samples/bind-width-height/expected-bundle.js | 2 +- .../collapses-text-around-comments/expected-bundle.js | 2 +- test/js/samples/component-static-array/expected-bundle.js | 3 ++- test/js/samples/component-static-array/expected.js | 1 + .../samples/component-static-immutable/expected-bundle.js | 3 ++- test/js/samples/component-static-immutable/expected.js | 1 + .../component-static-immutable2/expected-bundle.js | 3 ++- test/js/samples/component-static-immutable2/expected.js | 1 + test/js/samples/component-static/expected-bundle.js | 3 ++- test/js/samples/component-static/expected.js | 1 + test/js/samples/computed-collapsed-if/expected-bundle.js | 2 +- test/js/samples/css-media-query/expected-bundle.js | 2 +- .../samples/css-shadow-dom-keyframes/expected-bundle.js | 2 +- test/js/samples/deconflict-builtins/expected-bundle.js | 2 +- test/js/samples/deconflict-globals/expected-bundle.js | 2 +- .../dev-warning-missing-data-computed/expected-bundle.js | 2 +- test/js/samples/do-use-dataset/expected-bundle.js | 2 +- .../samples/dont-use-dataset-in-legacy/expected-bundle.js | 2 +- .../js/samples/dont-use-dataset-in-svg/expected-bundle.js | 2 +- .../samples/each-block-changed-check/expected-bundle.js | 2 +- .../samples/each-block-keyed-animated/expected-bundle.js | 2 +- test/js/samples/each-block-keyed/expected-bundle.js | 2 +- test/js/samples/event-handlers-custom/expected-bundle.js | 2 +- test/js/samples/head-no-whitespace/expected-bundle.js | 2 +- test/js/samples/if-block-no-update/expected-bundle.js | 2 +- test/js/samples/if-block-simple/expected-bundle.js | 2 +- .../inline-style-optimized-multiple/expected-bundle.js | 2 +- .../samples/inline-style-optimized-url/expected-bundle.js | 2 +- test/js/samples/inline-style-optimized/expected-bundle.js | 2 +- .../samples/inline-style-unoptimized/expected-bundle.js | 2 +- test/js/samples/input-range/expected-bundle.js | 2 +- .../input-without-blowback-guard/expected-bundle.js | 2 +- test/js/samples/legacy-input-type/expected-bundle.js | 2 +- test/js/samples/media-bindings/expected-bundle.js | 2 +- test/js/samples/non-imported-component/expected-bundle.js | 8 +++++--- test/js/samples/non-imported-component/expected.js | 6 ++++-- test/js/samples/setup-method/expected-bundle.js | 2 +- test/js/samples/svg-title/expected-bundle.js | 2 +- test/js/samples/title/expected-bundle.js | 2 +- .../js/samples/use-elements-as-anchors/expected-bundle.js | 2 +- test/js/samples/window-binding-scroll/expected-bundle.js | 2 +- 58 files changed, 77 insertions(+), 62 deletions(-) diff --git a/src/compile/nodes/Component.ts b/src/compile/nodes/Component.ts index c5efd25afb..736b2306ea 100644 --- a/src/compile/nodes/Component.ts +++ b/src/compile/nodes/Component.ts @@ -123,7 +123,7 @@ export default class Component extends Node { const name = this.var; - const componentInitProperties = [`root: #component.root`]; + const componentInitProperties = [`root: #component.root`, `store: #component.store`]; if (this.children.length > 0) { const slots = Array.from(this._slots).map(name => `${quoteNameIfNecessary(name)}: @createFragment()`); diff --git a/src/shared/index.js b/src/shared/index.js index c9d901af64..4d0e7896c6 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -64,7 +64,7 @@ export function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } export function on(eventName, handler) { diff --git a/test/cli/samples/basic/expected/Main.js b/test/cli/samples/basic/expected/Main.js index d42218c622..19de3981da 100644 --- a/test/cli/samples/basic/expected/Main.js +++ b/test/cli/samples/basic/expected/Main.js @@ -69,7 +69,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/custom-element/expected/Main.js b/test/cli/samples/custom-element/expected/Main.js index 74c99b1f1d..64981ea826 100644 --- a/test/cli/samples/custom-element/expected/Main.js +++ b/test/cli/samples/custom-element/expected/Main.js @@ -90,7 +90,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/dev/expected/Main.js b/test/cli/samples/dev/expected/Main.js index 664f9ec0b8..3808927235 100644 --- a/test/cli/samples/dev/expected/Main.js +++ b/test/cli/samples/dev/expected/Main.js @@ -93,7 +93,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js b/test/cli/samples/dir-sourcemap/expected/Main.js index 3d507d9867..85e8e85480 100644 --- a/test/cli/samples/dir-sourcemap/expected/Main.js +++ b/test/cli/samples/dir-sourcemap/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte vx.y.z */ +/* src/Main.html generated by Svelte v2.7.2 */ import Widget from './Widget.html'; @@ -6,7 +6,8 @@ import Widget from './Widget.html'; function create_main_fragment(component, ctx) { var widget = new Widget({ - root: component.root + root: component.root, + store: component.store }); return { @@ -72,7 +73,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js.map b/test/cli/samples/dir-sourcemap/expected/Main.js.map index e164b7b845..3177f8b8be 100644 --- a/test/cli/samples/dir-sourcemap/expected/Main.js.map +++ b/test/cli/samples/dir-sourcemap/expected/Main.js.map @@ -1 +1 @@ -{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/cli/samples/dir-sourcemap/expected/Widget.js b/test/cli/samples/dir-sourcemap/expected/Widget.js index 25e36da0dd..47794ea409 100644 --- a/test/cli/samples/dir-sourcemap/expected/Widget.js +++ b/test/cli/samples/dir-sourcemap/expected/Widget.js @@ -1,4 +1,4 @@ -/* src/Widget.html generated by Svelte vx.y.z */ +/* src/Widget.html generated by Svelte v2.7.2 */ function create_main_fragment(component, ctx) { var p; @@ -69,7 +69,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/dir-subdir/expected/Main.js b/test/cli/samples/dir-subdir/expected/Main.js index 73503e2106..a80bf2f976 100644 --- a/test/cli/samples/dir-subdir/expected/Main.js +++ b/test/cli/samples/dir-subdir/expected/Main.js @@ -6,7 +6,8 @@ import Widget from './widget/Widget.html'; function create_main_fragment(component, ctx) { var widget = new Widget({ - root: component.root + root: component.root, + store: component.store }); return { @@ -72,7 +73,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/dir-subdir/expected/widget/Widget.js b/test/cli/samples/dir-subdir/expected/widget/Widget.js index f27a3b1257..974326ad95 100644 --- a/test/cli/samples/dir-subdir/expected/widget/Widget.js +++ b/test/cli/samples/dir-subdir/expected/widget/Widget.js @@ -69,7 +69,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/dir/expected/Main.js b/test/cli/samples/dir/expected/Main.js index 017f054795..edfbe3c67f 100644 --- a/test/cli/samples/dir/expected/Main.js +++ b/test/cli/samples/dir/expected/Main.js @@ -6,7 +6,8 @@ import Widget from './Widget.html'; function create_main_fragment(component, ctx) { var widget = new Widget({ - root: component.root + root: component.root, + store: component.store }); return { @@ -72,7 +73,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/dir/expected/Widget.js b/test/cli/samples/dir/expected/Widget.js index cfc85b0c1c..7bec9ae438 100644 --- a/test/cli/samples/dir/expected/Widget.js +++ b/test/cli/samples/dir/expected/Widget.js @@ -69,7 +69,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/globals/expected/Main.js b/test/cli/samples/globals/expected/Main.js index 357e10b9c4..1a79813b58 100644 --- a/test/cli/samples/globals/expected/Main.js +++ b/test/cli/samples/globals/expected/Main.js @@ -90,7 +90,7 @@ var Main = (function(answer) { "use strict"; component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/sourcemap-inline/expected/Main.js b/test/cli/samples/sourcemap-inline/expected/Main.js index 78bc2da178..de6a8894ce 100644 --- a/test/cli/samples/sourcemap-inline/expected/Main.js +++ b/test/cli/samples/sourcemap-inline/expected/Main.js @@ -69,7 +69,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/sourcemap/expected/Main.js b/test/cli/samples/sourcemap/expected/Main.js index 70c50e76b5..e136e16f48 100644 --- a/test/cli/samples/sourcemap/expected/Main.js +++ b/test/cli/samples/sourcemap/expected/Main.js @@ -69,7 +69,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/cli/samples/store/expected/Main.js b/test/cli/samples/store/expected/Main.js index 0cadb9e366..3f97badad4 100644 --- a/test/cli/samples/store/expected/Main.js +++ b/test/cli/samples/store/expected/Main.js @@ -85,7 +85,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function assign(tar, src) { diff --git a/test/js/samples/action/expected-bundle.js b/test/js/samples/action/expected-bundle.js index fe61c32b09..e1b3e6ce18 100644 --- a/test/js/samples/action/expected-bundle.js +++ b/test/js/samples/action/expected-bundle.js @@ -61,7 +61,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/bind-width-height/expected-bundle.js b/test/js/samples/bind-width-height/expected-bundle.js index e66cc47aaf..8a441a8d3f 100644 --- a/test/js/samples/bind-width-height/expected-bundle.js +++ b/test/js/samples/bind-width-height/expected-bundle.js @@ -93,7 +93,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, 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 49c9c75813..87f65ba860 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -69,7 +69,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/component-static-array/expected-bundle.js b/test/js/samples/component-static-array/expected-bundle.js index 1fd894e093..5f85c7487a 100644 --- a/test/js/samples/component-static-array/expected-bundle.js +++ b/test/js/samples/component-static-array/expected-bundle.js @@ -49,7 +49,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { @@ -124,6 +124,7 @@ function create_main_fragment(component, ctx) { var nested_initial_data = { foo: [1, 2, 3] }; var nested = new Nested({ root: component.root, + store: component.store, data: nested_initial_data }); diff --git a/test/js/samples/component-static-array/expected.js b/test/js/samples/component-static-array/expected.js index c1dcfea4a7..bae0c850f7 100644 --- a/test/js/samples/component-static-array/expected.js +++ b/test/js/samples/component-static-array/expected.js @@ -8,6 +8,7 @@ function create_main_fragment(component, ctx) { var nested_initial_data = { foo: [1, 2, 3] }; var nested = new Nested({ root: component.root, + store: component.store, data: nested_initial_data }); diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js index dc6d94a1f2..3ebd360b2a 100644 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -53,7 +53,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { @@ -128,6 +128,7 @@ function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ root: component.root, + store: component.store, data: nested_initial_data }); diff --git a/test/js/samples/component-static-immutable/expected.js b/test/js/samples/component-static-immutable/expected.js index 41fe5a349b..f40f060325 100644 --- a/test/js/samples/component-static-immutable/expected.js +++ b/test/js/samples/component-static-immutable/expected.js @@ -8,6 +8,7 @@ function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ root: component.root, + store: component.store, data: nested_initial_data }); diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js index dc6d94a1f2..3ebd360b2a 100644 --- a/test/js/samples/component-static-immutable2/expected-bundle.js +++ b/test/js/samples/component-static-immutable2/expected-bundle.js @@ -53,7 +53,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { @@ -128,6 +128,7 @@ function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ root: component.root, + store: component.store, data: nested_initial_data }); diff --git a/test/js/samples/component-static-immutable2/expected.js b/test/js/samples/component-static-immutable2/expected.js index 41fe5a349b..f40f060325 100644 --- a/test/js/samples/component-static-immutable2/expected.js +++ b/test/js/samples/component-static-immutable2/expected.js @@ -8,6 +8,7 @@ function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ root: component.root, + store: component.store, data: nested_initial_data }); diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index 21c70ae9a7..d2c8280062 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -49,7 +49,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { @@ -124,6 +124,7 @@ function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ root: component.root, + store: component.store, data: nested_initial_data }); diff --git a/test/js/samples/component-static/expected.js b/test/js/samples/component-static/expected.js index 2318521cf4..1a5631fc58 100644 --- a/test/js/samples/component-static/expected.js +++ b/test/js/samples/component-static/expected.js @@ -8,6 +8,7 @@ function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ root: component.root, + store: component.store, data: nested_initial_data }); diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 0e967c7a67..73830ee233 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -49,7 +49,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index b481784118..ff7bdcfcc1 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -65,7 +65,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, 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 c34d69215b..8d9d31dff2 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -61,7 +61,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js index 976c71face..c3d9d762b9 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ b/test/js/samples/deconflict-builtins/expected-bundle.js @@ -79,7 +79,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index 524d379e88..0d2226d5cb 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -54,7 +54,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { 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 b26570734c..3b9a92c90e 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 @@ -82,7 +82,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js index 7eac008dbe..10c7600975 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -65,7 +65,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, 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 93fbd587cf..4a963e3300 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 @@ -69,7 +69,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, 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 349eff3f4d..5b1827344d 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 @@ -69,7 +69,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, 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 b06f8662f9..02db1ce829 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -81,7 +81,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/each-block-keyed-animated/expected-bundle.js b/test/js/samples/each-block-keyed-animated/expected-bundle.js index 54876c6152..9989c77978 100644 --- a/test/js/samples/each-block-keyed-animated/expected-bundle.js +++ b/test/js/samples/each-block-keyed-animated/expected-bundle.js @@ -391,7 +391,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/each-block-keyed/expected-bundle.js b/test/js/samples/each-block-keyed/expected-bundle.js index 89f1655008..09f61a6d3e 100644 --- a/test/js/samples/each-block-keyed/expected-bundle.js +++ b/test/js/samples/each-block-keyed/expected-bundle.js @@ -164,7 +164,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 5e04f88939..78d5d1a005 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -61,7 +61,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js index f7bbdcc431..d878a85cbf 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -61,7 +61,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, 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 358177436b..f07810c565 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -65,7 +65,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 6028d9dfc1..88729b1159 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -65,7 +65,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, 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 be92ba9730..37dd300b5d 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -65,7 +65,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, 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 439a9b8740..716dac771d 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -65,7 +65,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js index a5a474d08f..817462d0bd 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -65,7 +65,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js index f9611d370a..a378c2f4a6 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -65,7 +65,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/input-range/expected-bundle.js b/test/js/samples/input-range/expected-bundle.js index 61560074dc..108fc37a01 100644 --- a/test/js/samples/input-range/expected-bundle.js +++ b/test/js/samples/input-range/expected-bundle.js @@ -77,7 +77,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, 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 9a0998ed9a..e3fb0c60a4 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -73,7 +73,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index 41701a0b41..e1d6f84a8f 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -67,7 +67,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index 151a26f603..fd83ed3c68 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -77,7 +77,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 0cfeadbd9d..345d98d16e 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -63,7 +63,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { @@ -137,11 +137,13 @@ function create_main_fragment(component, ctx) { var text; var imported = new Imported({ - root: component.root + root: component.root, + store: component.store }); var nonimported = new NonImported({ - root: component.root + root: component.root, + store: component.store }); return { diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index e384445105..b3e01289c3 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -8,11 +8,13 @@ function create_main_fragment(component, ctx) { var text; var imported = new Imported({ - root: component.root + root: component.root, + store: component.store }); var nonimported = new NonImported({ - root: component.root + root: component.root, + store: component.store }); return { diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index da8d02f4d6..df0ea63860 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -49,7 +49,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index 948fb03a4d..4073da0148 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -69,7 +69,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index 1060deab4c..109ec3276b 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -49,7 +49,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, 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 979a7ff3e7..2771ac3719 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -73,7 +73,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index 7fdc38fc63..2d718e483f 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -69,7 +69,7 @@ function init(component, options) { component.options = options; component.root = options.root || component; - component.store = component.root.store || options.store; + component.store = options.store || component.root.store; } function on(eventName, handler) { From 17000e38f66d184389b8fd562a3a7f4b0a39bdb3 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 20 Jun 2018 14:23:23 -0400 Subject: [PATCH 007/187] -> v2.8.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5051a1b22..653a14ed76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Svelte changelog +## 2.8.0 + +* Correctly set store on nested components (to parent store, not root store) ([#1538](https://github.com/sveltejs/svelte/issues/1538)) + ## 2.7.2 * Prevent unnecessary remounts ([#1527](https://github.com/sveltejs/svelte/issues/1527)) diff --git a/package.json b/package.json index c1890ee3ae..b48344748c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "2.7.2", + "version": "2.8.0", "description": "The magical disappearing UI framework", "main": "compiler/svelte.js", "bin": { From c641ce423a711f31f044569ff95a3594d8561616 Mon Sep 17 00:00:00 2001 From: Fernando Jorge Mota Date: Fri, 22 Jun 2018 14:41:12 -0300 Subject: [PATCH 008/187] Quote name of attribute to nested components This fixes #887 by quoting name of attributes if those are invalid JS identifiers when passing data to nested components. --- src/compile/nodes/Component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compile/nodes/Component.ts b/src/compile/nodes/Component.ts index 736b2306ea..10ba66c413 100644 --- a/src/compile/nodes/Component.ts +++ b/src/compile/nodes/Component.ts @@ -148,7 +148,7 @@ export default class Component extends Node { const attributeObject = usesSpread ? '{}' : stringifyProps( - this.attributes.map(attr => `${attr.name}: ${attr.getValue()}`) + this.attributes.map(attr => `${quoteNameIfNecessary(attr.name)}: ${attr.getValue()}`) ); if (this.attributes.length || this.bindings.length) { From fe9a68d071f05e7f613a235027829c2d7c879529 Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Fri, 22 Jun 2018 14:55:13 -0300 Subject: [PATCH 009/187] Fix prefixed animation name replacement --- .editorconfig | 3 +++ src/css/Stylesheet.ts | 6 ++++-- src/utils/isKeyframesNode.ts | 7 ------- src/utils/removeCSSPrefix.ts | 3 +++ test/css/samples/keyframes-autoprefixed/expected.css | 2 +- test/css/samples/keyframes-autoprefixed/input.html | 2 ++ 6 files changed, 13 insertions(+), 10 deletions(-) delete mode 100644 src/utils/isKeyframesNode.ts create mode 100644 src/utils/removeCSSPrefix.ts diff --git a/.editorconfig b/.editorconfig index 854167bbed..ed2a319d58 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,6 +8,9 @@ indent_size = 2 charset = utf-8 trim_trailing_whitespace = true +[test/**/expected.css] +insert_final_newline = false + [{package.json,.travis.yml,.eslintrc.json}] indent_style = space indent_size = 2 diff --git a/src/css/Stylesheet.ts b/src/css/Stylesheet.ts index 8dadc4e296..32052f50d5 100644 --- a/src/css/Stylesheet.ts +++ b/src/css/Stylesheet.ts @@ -4,11 +4,13 @@ import { getLocator } from 'locate-character'; import Selector from './Selector'; import getCodeFrame from '../utils/getCodeFrame'; import hash from '../utils/hash'; -import isKeyframesNode from '../utils/isKeyframesNode'; +import removeCSSPrefix from '../utils/removeCSSPrefix'; import Element from '../compile/nodes/Element'; import { Validator } from '../validate/index'; import { Node, Ast, Warning } from '../interfaces'; +const isKeyframesNode = (node: Node) => removeCSSPrefix(node.name) === 'keyframes' + class Rule { selectors: Selector[]; declarations: Declaration[]; @@ -97,7 +99,7 @@ class Declaration { } transform(code: MagicString, keyframes: Map) { - const property = this.node.property && this.node.property.toLowerCase(); + const property = this.node.property && removeCSSPrefix(this.node.property.toLowerCase()); if (property === 'animation' || property === 'animation-name') { this.node.value.children.forEach((block: Node) => { if (block.type === 'Identifier') { diff --git a/src/utils/isKeyframesNode.ts b/src/utils/isKeyframesNode.ts deleted file mode 100644 index 4ce899ff99..0000000000 --- a/src/utils/isKeyframesNode.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Node } from '../interfaces'; - -export default function isKeyframesNode(node: Node): boolean { - return ['', '-webkit-', '-moz-', '-o-'].some( - prefix => node.name === `${prefix}keyframes` - ); -} diff --git a/src/utils/removeCSSPrefix.ts b/src/utils/removeCSSPrefix.ts new file mode 100644 index 0000000000..df1849f119 --- /dev/null +++ b/src/utils/removeCSSPrefix.ts @@ -0,0 +1,3 @@ +export default function(name: string): string { + return name.replace(/^-((webkit)|(moz)|(o)|(ms))-/, ''); +} diff --git a/test/css/samples/keyframes-autoprefixed/expected.css b/test/css/samples/keyframes-autoprefixed/expected.css index a50a2b94d3..d9866778a9 100644 --- a/test/css/samples/keyframes-autoprefixed/expected.css +++ b/test/css/samples/keyframes-autoprefixed/expected.css @@ -1 +1 @@ -@keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-webkit-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-moz-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-o-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}.animated.svelte-xyz{animation:svelte-xyz-why 2s}.also-animated.svelte-xyz{animation:not-defined-here 2s} \ No newline at end of file +@keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-webkit-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-moz-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-o-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}.animated.svelte-xyz{-webkit-animation:svelte-xyz-why 2s;animation:svelte-xyz-why 2s}.also-animated.svelte-xyz{-webkit-animation:not-defined-here 2s;animation:not-defined-here 2s} \ No newline at end of file diff --git a/test/css/samples/keyframes-autoprefixed/input.html b/test/css/samples/keyframes-autoprefixed/input.html index dfe5dd4578..1c0e1bc630 100644 --- a/test/css/samples/keyframes-autoprefixed/input.html +++ b/test/css/samples/keyframes-autoprefixed/input.html @@ -23,10 +23,12 @@ } .animated { + -webkit-animation: why 2s; animation: why 2s; } .also-animated { + -webkit-animation: not-defined-here 2s; animation: not-defined-here 2s; } From f1fc81a49f5a399f0c3687bad96a135b0fbc4e65 Mon Sep 17 00:00:00 2001 From: Pavel Malyshev Date: Fri, 22 Jun 2018 21:05:29 +0300 Subject: [PATCH 010/187] Fix for #1553 --- src/compile/nodes/EventHandler.ts | 4 ++-- test/js/samples/event-handlers-custom/expected-bundle.js | 2 +- test/js/samples/event-handlers-custom/expected.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compile/nodes/EventHandler.ts b/src/compile/nodes/EventHandler.ts index 54dbd66157..6c15de7efd 100644 --- a/src/compile/nodes/EventHandler.ts +++ b/src/compile/nodes/EventHandler.ts @@ -67,12 +67,12 @@ export default class EventHandler extends Node { compiler.code.overwrite( this.insertionPoint, this.insertionPoint + 1, - `${component}.store.` + `return ${component}.store.` ); } else { compiler.code.prependRight( this.insertionPoint, - `${component}.` + `return ${component}.` ); } } diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 78d5d1a005..501b2a9a3f 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -146,7 +146,7 @@ function create_main_fragment(component, ctx) { button = createElement("button"); button.textContent = "foo"; foo_handler = foo.call(component, button, function(event) { - component.foo( ctx.bar ); + return component.foo( ctx.bar ); }); }, diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index c72362620b..855bea59ba 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -19,7 +19,7 @@ function create_main_fragment(component, ctx) { button = createElement("button"); button.textContent = "foo"; foo_handler = foo.call(component, button, function(event) { - component.foo( ctx.bar ); + return component.foo( ctx.bar ); }); }, From ce575e106502624cddd23ba1d8c0e565e51dcb20 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 22 Jun 2018 20:08:51 -0400 Subject: [PATCH 011/187] Revert "Fix for #1553" --- src/compile/nodes/EventHandler.ts | 4 ++-- test/js/samples/event-handlers-custom/expected-bundle.js | 2 +- test/js/samples/event-handlers-custom/expected.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compile/nodes/EventHandler.ts b/src/compile/nodes/EventHandler.ts index 6c15de7efd..54dbd66157 100644 --- a/src/compile/nodes/EventHandler.ts +++ b/src/compile/nodes/EventHandler.ts @@ -67,12 +67,12 @@ export default class EventHandler extends Node { compiler.code.overwrite( this.insertionPoint, this.insertionPoint + 1, - `return ${component}.store.` + `${component}.store.` ); } else { compiler.code.prependRight( this.insertionPoint, - `return ${component}.` + `${component}.` ); } } diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 501b2a9a3f..78d5d1a005 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -146,7 +146,7 @@ function create_main_fragment(component, ctx) { button = createElement("button"); button.textContent = "foo"; foo_handler = foo.call(component, button, function(event) { - return component.foo( ctx.bar ); + component.foo( ctx.bar ); }); }, diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index 855bea59ba..c72362620b 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -19,7 +19,7 @@ function create_main_fragment(component, ctx) { button = createElement("button"); button.textContent = "foo"; foo_handler = foo.call(component, button, function(event) { - return component.foo( ctx.bar ); + component.foo( ctx.bar ); }); }, From bec49a0ad08489cd3fefbe348bd6807575191604 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 22 Jun 2018 20:19:25 -0400 Subject: [PATCH 012/187] -> v2.8.1 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 653a14ed76..d3e7b5a137 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Svelte changelog +## 2.8.1 + +* Fix prefixed animation name replacement ([#1556](https://github.com/sveltejs/svelte/pull/1556)) + ## 2.8.0 * Correctly set store on nested components (to parent store, not root store) ([#1538](https://github.com/sveltejs/svelte/issues/1538)) diff --git a/package.json b/package.json index b48344748c..16f3142e90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "2.8.0", + "version": "2.8.1", "description": "The magical disappearing UI framework", "main": "compiler/svelte.js", "bin": { From 9a0af96c44209dcc6e0d7c3b5ba4d75bf0b804e6 Mon Sep 17 00:00:00 2001 From: Fernando Jorge Mota Date: Mon, 25 Jun 2018 03:31:04 -0300 Subject: [PATCH 013/187] Support invalid JS attributes when passing data to components and on binding attributes, too --- src/compile/nodes/Component.ts | 38 +++++++++---------- .../Counter.html | 14 +++++++ .../_config.js | 29 ++++++++++++++ .../main.html | 12 ++++++ .../component-invalid-identifier/Widget.html | 10 +++++ .../component-invalid-identifier/_config.js | 3 ++ .../component-invalid-identifier/main.html | 11 ++++++ 7 files changed, 98 insertions(+), 19 deletions(-) create mode 100644 test/runtime/samples/component-binding-invalid-identifier/Counter.html create mode 100644 test/runtime/samples/component-binding-invalid-identifier/_config.js create mode 100644 test/runtime/samples/component-binding-invalid-identifier/main.html create mode 100644 test/runtime/samples/component-invalid-identifier/Widget.html create mode 100644 test/runtime/samples/component-invalid-identifier/_config.js create mode 100644 test/runtime/samples/component-invalid-identifier/main.html diff --git a/src/compile/nodes/Component.ts b/src/compile/nodes/Component.ts index 10ba66c413..9465e2aaa7 100644 --- a/src/compile/nodes/Component.ts +++ b/src/compile/nodes/Component.ts @@ -5,7 +5,7 @@ import stringifyProps from '../../utils/stringifyProps'; import CodeBuilder from '../../utils/CodeBuilder'; import getTailSnippet from '../../utils/getTailSnippet'; import getObject from '../../utils/getObject'; -import { quoteNameIfNecessary } from '../../utils/quoteIfNecessary'; +import { quoteNameIfNecessary, quotePropIfNecessary } from '../../utils/quoteIfNecessary'; import { escape, escapeTemplate, stringify } from '../../utils/stringify'; import Node from './shared/Node'; import Block from '../dom/Block'; @@ -219,7 +219,7 @@ export default class Component extends Node { updates.push(deindent` if (${[...attribute.dependencies] .map(dependency => `changed.${dependency}`) - .join(' || ')}) ${name_changes}.${attribute.name} = ${attribute.getValue()}; + .join(' || ')}) ${name_changes}${quotePropIfNecessary(attribute.name)} = ${attribute.getValue()}; `); } }); @@ -250,10 +250,10 @@ export default class Component extends Node { const lhs = binding.value.node.type === 'MemberExpression' ? binding.value.snippet - : `${head}${tail} = childState.${binding.name}`; + : `${head}${tail} = childState${quotePropIfNecessary(binding.name)}`; setFromChild = deindent` - ${lhs} = childState.${binding.name}; + ${lhs} = childState${quotePropIfNecessary(binding.name)}; ${[...binding.value.dependencies] .map((name: string) => { @@ -264,7 +264,7 @@ export default class Component extends Node { if (isStoreProp) hasStoreBindings = true; else hasLocalBindings = true; - return `${newState}.${prop} = ctx.${name};`; + return `${newState}${quotePropIfNecessary(prop)} = ctx${quotePropIfNecessary(name)};`; })} `; } @@ -279,32 +279,32 @@ export default class Component extends Node { if (binding.value.node.type === 'MemberExpression') { setFromChild = deindent` - ${binding.value.snippet} = childState.${binding.name}; - ${newState}.${prop} = ctx.${key}; + ${binding.value.snippet} = childState${quotePropIfNecessary(binding.name)}; + ${newState}${quotePropIfNecessary(prop)} = ctx${quotePropIfNecessary(key)}; `; } else { - setFromChild = `${newState}.${prop} = childState.${binding.name};`; + setFromChild = `${newState}${quotePropIfNecessary(prop)} = childState${quotePropIfNecessary(binding.name)};`; } } statements.push(deindent` if (${binding.value.snippet} !== void 0) { - ${name_initial_data}.${binding.name} = ${binding.value.snippet}; - ${name_updating}.${binding.name} = true; + ${name_initial_data}${quotePropIfNecessary(binding.name)} = ${binding.value.snippet}; + ${name_updating}${quotePropIfNecessary(binding.name)} = true; }` ); builder.addConditional( - `!${name_updating}.${binding.name} && changed.${binding.name}`, + `!${name_updating}${quotePropIfNecessary(binding.name)} && changed${quotePropIfNecessary(binding.name)}`, setFromChild ); updates.push(deindent` - if (!${name_updating}.${binding.name} && ${[...binding.value.dependencies].map((dependency: string) => `changed.${dependency}`).join(' || ')}) { - ${name_changes}.${binding.name} = ${binding.value.snippet}; - ${name_updating}.${binding.name} = ${binding.value.snippet} !== void 0; + if (!${name_updating}${quotePropIfNecessary(binding.name)} && ${[...binding.value.dependencies].map((dependency: string) => `changed.${dependency}`).join(' || ')}) { + ${name_changes}${quotePropIfNecessary(binding.name)} = ${binding.value.snippet}; + ${name_updating}${quotePropIfNecessary(binding.name)} = ${binding.value.snippet} !== void 0; } `); }); @@ -329,7 +329,7 @@ export default class Component extends Node { beforecreate = deindent` #component.root._beforecreate.push(() => { - ${name}._bind({ ${this.bindings.map(b => `${b.name}: 1`).join(', ')} }, ${name}.get()); + ${name}._bind({ ${this.bindings.map(b => `${quoteNameIfNecessary(b.name)}: 1`).join(', ')} }, ${name}.get()); }); `; } @@ -519,7 +519,7 @@ export default class Component extends Node { ? getTailSnippet(binding.value.node) : ''; - return `${binding.name}: ctx.${name}${tail}`; + return `${quoteNameIfNecessary(binding.name)}: ctx${quotePropIfNecessary(name)}${tail}`; }); function getAttributeValue(attribute) { @@ -547,14 +547,14 @@ export default class Component extends Node { if (attribute.isSpread) { return attribute.expression.snippet; } else { - return `{ ${attribute.name}: ${getAttributeValue(attribute)} }`; + return `{ ${quoteNameIfNecessary(attribute.name)}: ${getAttributeValue(attribute)} }`; } }) .concat(bindingProps.map(p => `{ ${p} }`)) .join(', ') })` : `{ ${this.attributes - .map(attribute => `${attribute.name}: ${getAttributeValue(attribute)}`) + .map(attribute => `${quoteNameIfNecessary(attribute.name)}: ${getAttributeValue(attribute)}`) .concat(bindingProps) .join(', ')} }`; @@ -585,7 +585,7 @@ export default class Component extends Node { if (${conditions.reverse().join('&&')}) { tmp = ${expression}.data(); if ('${name}' in tmp) { - ctx.${binding.name} = tmp.${name}; + ctx${quotePropIfNecessary(binding.name)} = tmp.${name}; settled = false; } } diff --git a/test/runtime/samples/component-binding-invalid-identifier/Counter.html b/test/runtime/samples/component-binding-invalid-identifier/Counter.html new file mode 100644 index 0000000000..afb4ac7d58 --- /dev/null +++ b/test/runtime/samples/component-binding-invalid-identifier/Counter.html @@ -0,0 +1,14 @@ + + + diff --git a/test/runtime/samples/component-binding-invalid-identifier/_config.js b/test/runtime/samples/component-binding-invalid-identifier/_config.js new file mode 100644 index 0000000000..aa64ab81b8 --- /dev/null +++ b/test/runtime/samples/component-binding-invalid-identifier/_config.js @@ -0,0 +1,29 @@ +export default { + 'skip-ssr': true, // TODO delete this line, once binding works + + html: ` + +

count: 0

+ `, + + test ( assert, component, target, window ) { + const click = new window.MouseEvent( 'click' ); + const button = target.querySelector( 'button' ); + + button.dispatchEvent( click ); + + assert.equal( component.get().x, 1 ); + assert.htmlEqual( target.innerHTML, ` + +

count: 1

+ ` ); + + button.dispatchEvent( click ); + + assert.equal( component.get().x, 2 ); + assert.htmlEqual( target.innerHTML, ` + +

count: 2

+ ` ); + } +}; diff --git a/test/runtime/samples/component-binding-invalid-identifier/main.html b/test/runtime/samples/component-binding-invalid-identifier/main.html new file mode 100644 index 0000000000..90dcbfe34d --- /dev/null +++ b/test/runtime/samples/component-binding-invalid-identifier/main.html @@ -0,0 +1,12 @@ + +

count: {x}

+ + diff --git a/test/runtime/samples/component-invalid-identifier/Widget.html b/test/runtime/samples/component-invalid-identifier/Widget.html new file mode 100644 index 0000000000..779a912f2d --- /dev/null +++ b/test/runtime/samples/component-invalid-identifier/Widget.html @@ -0,0 +1,10 @@ +

{state["b-c"]}

+ diff --git a/test/runtime/samples/component-invalid-identifier/_config.js b/test/runtime/samples/component-invalid-identifier/_config.js new file mode 100644 index 0000000000..d768ccd1c7 --- /dev/null +++ b/test/runtime/samples/component-invalid-identifier/_config.js @@ -0,0 +1,3 @@ +export default { + html: '

i am a widget

' +}; diff --git a/test/runtime/samples/component-invalid-identifier/main.html b/test/runtime/samples/component-invalid-identifier/main.html new file mode 100644 index 0000000000..9a34311984 --- /dev/null +++ b/test/runtime/samples/component-invalid-identifier/main.html @@ -0,0 +1,11 @@ +
+ +
+ + From bde21dad873c70d1c94a012e9dbdfe3805965e77 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 28 Jun 2018 23:12:04 -0400 Subject: [PATCH 014/187] outro when switches - #1568 --- src/compile/nodes/Component.ts | 19 ++++++---- .../transition-js-dynamic-component/A.html | 16 ++++++++ .../transition-js-dynamic-component/B.html | 16 ++++++++ .../_config.js | 37 +++++++++++++++++++ .../transition-js-dynamic-component/main.html | 12 ++++++ 5 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 test/runtime/samples/transition-js-dynamic-component/A.html create mode 100644 test/runtime/samples/transition-js-dynamic-component/B.html create mode 100644 test/runtime/samples/transition-js-dynamic-component/_config.js create mode 100644 test/runtime/samples/transition-js-dynamic-component/main.html diff --git a/src/compile/nodes/Component.ts b/src/compile/nodes/Component.ts index 736b2306ea..48f5f0abaf 100644 --- a/src/compile/nodes/Component.ts +++ b/src/compile/nodes/Component.ts @@ -1,6 +1,4 @@ import deindent from '../../utils/deindent'; -import flattenReference from '../../utils/flattenReference'; -import validCalleeObjects from '../../utils/validCalleeObjects'; import stringifyProps from '../../utils/stringifyProps'; import CodeBuilder from '../../utils/CodeBuilder'; import getTailSnippet from '../../utils/getTailSnippet'; @@ -10,7 +8,6 @@ import { escape, escapeTemplate, stringify } from '../../utils/stringify'; import Node from './shared/Node'; import Block from '../dom/Block'; import Attribute from './Attribute'; -import usesThisOrArguments from '../../validate/js/utils/usesThisOrArguments'; import mapChildren from './shared/mapChildren'; import Binding from './Binding'; import EventHandler from './EventHandler'; @@ -344,9 +341,7 @@ export default class Component extends Node { const switch_value = block.getUniqueName('switch_value'); const switch_props = block.getUniqueName('switch_props'); - const { dependencies, snippet } = this.expression; - - const anchor = this.getOrCreateAnchor(block, parentNode, parentNodes); + const { snippet } = this.expression; block.builders.init.addBlock(deindent` var ${switch_value} = ${snippet}; @@ -392,6 +387,7 @@ export default class Component extends Node { } `); + const anchor = this.getOrCreateAnchor(block, parentNode, parentNodes); const updateMountNode = this.getUpdateMountNode(anchor); if (updates.length) { @@ -402,7 +398,16 @@ export default class Component extends Node { block.builders.update.addBlock(deindent` if (${switch_value} !== (${switch_value} = ${snippet})) { - if (${name}) ${name}.destroy(); + if (${name}) { + ${this.compiler.options.nestedTransitions + ? deindent` + @transitionManager.groupOutros(); + const old_component = ${name}; + old_component._fragment.o(() => { + old_component.destroy(); + });` + : `${name}.destroy();`} + } if (${switch_value}) { ${name} = new ${switch_value}(${switch_props}(ctx)); diff --git a/test/runtime/samples/transition-js-dynamic-component/A.html b/test/runtime/samples/transition-js-dynamic-component/A.html new file mode 100644 index 0000000000..7671fb5c58 --- /dev/null +++ b/test/runtime/samples/transition-js-dynamic-component/A.html @@ -0,0 +1,16 @@ +
a
+ + \ No newline at end of file diff --git a/test/runtime/samples/transition-js-dynamic-component/B.html b/test/runtime/samples/transition-js-dynamic-component/B.html new file mode 100644 index 0000000000..4ebe317cac --- /dev/null +++ b/test/runtime/samples/transition-js-dynamic-component/B.html @@ -0,0 +1,16 @@ +
b
+ + \ No newline at end of file diff --git a/test/runtime/samples/transition-js-dynamic-component/_config.js b/test/runtime/samples/transition-js-dynamic-component/_config.js new file mode 100644 index 0000000000..bb4cace57e --- /dev/null +++ b/test/runtime/samples/transition-js-dynamic-component/_config.js @@ -0,0 +1,37 @@ +export default { + nestedTransitions: true, + skipIntroByDefault: true, + + data: { + x: true, + }, + + html: ` +
a
+ `, + + test (assert, component, target, window, raf) { + component.set({ x: false }); + + assert.htmlEqual(target.innerHTML, ` +
a
+
b
+ `); + + const [a, b] = target.querySelectorAll('div'); + + raf.tick(25); + + assert.equal(a.a, 0.75); + assert.equal(b.b, 0.25); + + raf.tick(100); + + assert.equal(a.a, 0); + assert.equal(b.b, 1); + + assert.htmlEqual(target.innerHTML, ` +
b
+ `); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/transition-js-dynamic-component/main.html b/test/runtime/samples/transition-js-dynamic-component/main.html new file mode 100644 index 0000000000..02983215cc --- /dev/null +++ b/test/runtime/samples/transition-js-dynamic-component/main.html @@ -0,0 +1,12 @@ + + + \ No newline at end of file From 7678b36581a200a8376b16960eb9f73e25f2bb9d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 28 Jun 2018 23:49:16 -0400 Subject: [PATCH 015/187] separate groupOutros from transitionsManager --- src/compile/Compiler.ts | 8 ++++--- src/compile/nodes/Component.ts | 2 +- src/compile/nodes/EachBlock.ts | 4 ++-- src/compile/nodes/IfBlock.ts | 4 ++-- src/shared/_build.js | 2 +- src/shared/await-block.js | 4 ++-- src/shared/transitions.js | 21 +++++++++++-------- .../expected-bundle.js | 7 ------- 8 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/compile/Compiler.ts b/src/compile/Compiler.ts index 4a4239bbae..bb2ffd1d5e 100644 --- a/src/compile/Compiler.ts +++ b/src/compile/Compiler.ts @@ -303,11 +303,13 @@ export default class Compiler { }, }); - if (name === 'transitionManager') { + if (name === 'transitionManager' || name === 'outros') { // special case - const global = `_svelteTransitionManager`; + const global = name === 'outros' + ? `_svelteOutros` + : `_svelteTransitionManager`; - inlineHelpers += `\n\nvar ${this.alias('transitionManager')} = window.${global} || (window.${global} = ${code});\n\n`; + inlineHelpers += `\n\nvar ${this.alias(name)} = window.${global} || (window.${global} = ${code});\n\n`; } else if (name === 'escaped' || name === 'missingComponent') { // vars are an awkward special case... would be nice to avoid this const alias = this.alias(name); diff --git a/src/compile/nodes/Component.ts b/src/compile/nodes/Component.ts index 48f5f0abaf..ebe396b709 100644 --- a/src/compile/nodes/Component.ts +++ b/src/compile/nodes/Component.ts @@ -401,7 +401,7 @@ export default class Component extends Node { if (${name}) { ${this.compiler.options.nestedTransitions ? deindent` - @transitionManager.groupOutros(); + @groupOutros(); const old_component = ${name}; old_component._fragment.o(() => { old_component.destroy(); diff --git a/src/compile/nodes/EachBlock.ts b/src/compile/nodes/EachBlock.ts index adf23d85c9..a29877367e 100644 --- a/src/compile/nodes/EachBlock.ts +++ b/src/compile/nodes/EachBlock.ts @@ -324,7 +324,7 @@ export default class EachBlock extends Node { block.builders.update.addBlock(deindent` const ${this.each_block_value} = ${snippet}; - ${this.block.hasOutros && `@transitionManager.groupOutros();`} + ${this.block.hasOutros && `@groupOutros();`} ${this.block.hasAnimation && `for (let #i = 0; #i < ${blocks}.length; #i += 1) ${blocks}[#i].r();`} ${blocks} = @updateKeyedEach(${blocks}, #component, changed, ${get_key}, ${dynamic ? '1' : '0'}, ctx, ${this.each_block_value}, ${lookup}, ${updateMountNode}, ${destroy}, ${create_each_block}, "${mountOrIntro}", ${anchor}, ${this.get_each_context}); ${this.block.hasAnimation && `for (let #i = 0; #i < ${blocks}.length; #i += 1) ${blocks}[#i].a();`} @@ -449,7 +449,7 @@ export default class EachBlock extends Node { if (this.block.hasOutros) { destroy = deindent` - @transitionManager.groupOutros(); + @groupOutros(); for (; #i < ${iterations}.length; #i += 1) ${outroBlock}(#i, 1); `; } else { diff --git a/src/compile/nodes/IfBlock.ts b/src/compile/nodes/IfBlock.ts index ee5cb41a83..730128fc71 100644 --- a/src/compile/nodes/IfBlock.ts +++ b/src/compile/nodes/IfBlock.ts @@ -301,7 +301,7 @@ export default class IfBlock extends Node { const updateMountNode = this.getUpdateMountNode(anchor); const destroyOldBlock = deindent` - @transitionManager.groupOutros(); + @groupOutros(); ${name}.o(function() { ${if_blocks}[${previous_block_index}].d(1); ${if_blocks}[${previous_block_index}] = null; @@ -423,7 +423,7 @@ export default class IfBlock extends Node { // as that will typically result in glitching const exit = branch.hasOutroMethod ? deindent` - @transitionManager.groupOutros(); + @groupOutros(); ${name}.o(function() { ${name}.d(1); ${name} = null; diff --git a/src/shared/_build.js b/src/shared/_build.js index d62a5602e3..79d9f56774 100644 --- a/src/shared/_build.js +++ b/src/shared/_build.js @@ -27,7 +27,7 @@ fs.readdirSync(__dirname).forEach(file => { ? declaration.declarations[0].init : declaration; - declarations[name] = source.slice(value.start, value.end); + declarations[name] = value ? source.slice(value.start, value.end) : 'null'; }); }); diff --git a/src/shared/await-block.js b/src/shared/await-block.js index f5aceaf163..ed4b2ccf26 100644 --- a/src/shared/await-block.js +++ b/src/shared/await-block.js @@ -1,5 +1,5 @@ import { assign, isPromise } from './utils.js'; -import { transitionManager } from './transitions.js'; +import { groupOutros } from './transitions.js'; export function handlePromise(promise, info) { var token = info.token = {}; @@ -16,7 +16,7 @@ export function handlePromise(promise, info) { if (info.blocks) { info.blocks.forEach((block, i) => { if (i !== index && block) { - transitionManager.groupOutros(); + groupOutros(); block.o(() => { block.d(1); info.blocks[i] = null; diff --git a/src/shared/transitions.js b/src/shared/transitions.js index 5f33c27dff..33903e9cbd 100644 --- a/src/shared/transitions.js +++ b/src/shared/transitions.js @@ -72,8 +72,8 @@ export function wrapTransition(component, node, fn, params, intro) { } if (!b) { - program.group = transitionManager.outros; - transitionManager.outros.remaining += 1; + program.group = outros; + outros.remaining += 1; } if (obj.delay) { @@ -165,6 +165,16 @@ export function wrapTransition(component, node, fn, params, intro) { }; } +export let outros = { + remaining: 0, + callbacks: [] +}; + +export function groupOutros() { + outros.remaining = 0; + outros.callbacks = []; +} + export var transitionManager = { running: false, transitions: [], @@ -236,13 +246,6 @@ export var transitionManager = { .join(', '); }, - groupOutros() { - this.outros = { - remaining: 0, - callbacks: [] - }; - }, - wait() { if (!transitionManager.promise) { transitionManager.promise = Promise.resolve(); diff --git a/test/js/samples/each-block-keyed-animated/expected-bundle.js b/test/js/samples/each-block-keyed-animated/expected-bundle.js index 9989c77978..b1ecb4ce56 100644 --- a/test/js/samples/each-block-keyed-animated/expected-bundle.js +++ b/test/js/samples/each-block-keyed-animated/expected-bundle.js @@ -125,13 +125,6 @@ var transitionManager = { .join(', '); }, - groupOutros() { - this.outros = { - remaining: 0, - callbacks: [] - }; - }, - wait() { if (!transitionManager.promise) { transitionManager.promise = Promise.resolve(); From f3e4f04a5454d018544036190ca6a6c30158ca29 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 29 Jun 2018 15:04:45 -0400 Subject: [PATCH 016/187] abort transition on detach - alternative fix for #1561 --- src/compile/nodes/Element.ts | 10 +++++++--- src/shared/transitions.js | 4 ++-- .../_config.js | 19 +++++++++++++++++++ .../main.html | 18 ++++++++++++++++++ 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 test/runtime/samples/transition-js-destroyed-before-end/_config.js create mode 100644 test/runtime/samples/transition-js-destroyed-before-end/main.html diff --git a/src/compile/nodes/Element.ts b/src/compile/nodes/Element.ts index 6c174f0272..12cffbbebf 100644 --- a/src/compile/nodes/Element.ts +++ b/src/compile/nodes/Element.ts @@ -712,6 +712,8 @@ export default class Element extends Node { ${name} = null; }); `); + + block.builders.destroy.addConditional('detach', `if (${name}) ${name}.abort();`); } else { const introName = intro && block.getUniqueName(`${this.var}_intro`); const outroName = outro && block.getUniqueName(`${this.var}_outro`); @@ -726,8 +728,8 @@ export default class Element extends Node { if (outro) { block.builders.intro.addBlock(deindent` - if (${introName}) ${introName}.abort(); - if (${outroName}) ${outroName}.abort(); + if (${introName}) ${introName}.abort(1); + if (${outroName}) ${outroName}.abort(1); `); } @@ -748,7 +750,7 @@ export default class Element extends Node { const fn = `%transitions-${outro.name}`; block.builders.intro.addBlock(deindent` - if (${outroName}) ${outroName}.abort(); + if (${outroName}) ${outroName}.abort(1); `); // TODO hide elements that have outro'd (unless they belong to a still-outroing @@ -757,6 +759,8 @@ export default class Element extends Node { ${outroName} = @wrapTransition(#component, ${this.var}, ${fn}, ${snippet}, false); ${outroName}.run(0, #outrocallback); `); + + block.builders.destroy.addConditional('detach', `if (${outroName}) ${outroName}.abort();`); } } } diff --git a/src/shared/transitions.js b/src/shared/transitions.js index 5f33c27dff..4bbe8e0455 100644 --- a/src/shared/transitions.js +++ b/src/shared/transitions.js @@ -148,9 +148,9 @@ export function wrapTransition(component, node, fn, params, intro) { this.running = !!this.pending; }, - abort() { + abort(reset) { if (this.program) { - if (obj.tick) obj.tick(1, 0); + if (reset && obj.tick) obj.tick(1, 0); if (obj.css) transitionManager.deleteRule(node, this.program.name); this.program = this.pending = null; this.running = false; diff --git a/test/runtime/samples/transition-js-destroyed-before-end/_config.js b/test/runtime/samples/transition-js-destroyed-before-end/_config.js new file mode 100644 index 0000000000..d079c44641 --- /dev/null +++ b/test/runtime/samples/transition-js-destroyed-before-end/_config.js @@ -0,0 +1,19 @@ +export default { + skipIntroByDefault: true, + + data: { + visible: true + }, + + test(assert, component, target, window, raf) { + component.set({ visible: false }); + const div = target.querySelector('div'); + + raf.tick(50); + assert.equal(div.foo, 0.5); + + component.destroy(); + + raf.tick(100); + }, +}; diff --git a/test/runtime/samples/transition-js-destroyed-before-end/main.html b/test/runtime/samples/transition-js-destroyed-before-end/main.html new file mode 100644 index 0000000000..e6e0ee0c63 --- /dev/null +++ b/test/runtime/samples/transition-js-destroyed-before-end/main.html @@ -0,0 +1,18 @@ +{#if visible} +
destroy me
+{/if} + + \ No newline at end of file From 6c20d147897d907b0fa40ab0ad131becbb6878a9 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 29 Jun 2018 16:24:11 -0400 Subject: [PATCH 017/187] remove unused import --- src/shared/keyed-each.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/shared/keyed-each.js b/src/shared/keyed-each.js index 9ec3d1c622..d3afde60fb 100644 --- a/src/shared/keyed-each.js +++ b/src/shared/keyed-each.js @@ -1,5 +1,3 @@ -import { transitionManager, linear, generateRule, hash } from './transitions'; - export function destroyBlock(block, lookup) { block.d(1); lookup[block.key] = null; From 2bb62c3436038a442d27953287a25c6a1b1adddd Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 29 Jun 2018 17:53:16 -0400 Subject: [PATCH 018/187] -> v2.9.0 --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e7b5a137..142e7d8e30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Svelte changelog +## 2.9.0 + +* Play outro transitions on `` if `nestedTransitions` is true ([#1568](https://github.com/sveltejs/svelte/issues/1568)) +* Allow illegal identifiers to be component prop names, for e.g. spreading `data-foo` props ([#887](https://github.com/sveltejs/svelte/issues/887)) +* Abort transition when node is detached ([#1561](https://github.com/sveltejs/svelte/issues/1561)) +* Only include `transitionManager` when necessary ([#1514](https://github.com/sveltejs/svelte/issues/1514)) + ## 2.8.1 * Fix prefixed animation name replacement ([#1556](https://github.com/sveltejs/svelte/pull/1556)) diff --git a/package.json b/package.json index 16f3142e90..d619ccebcf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "2.8.1", + "version": "2.9.0", "description": "The magical disappearing UI framework", "main": "compiler/svelte.js", "bin": { From 5ff7cb51dcb676aa76cfe1cda36371672f280c69 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 1 Jul 2018 14:04:04 -0400 Subject: [PATCH 019/187] use template.content in place of template where appropriate - fixes #1571 --- src/compile/nodes/Element.ts | 40 +++++++++++------------- test/runtime/samples/template/_config.js | 23 ++++++++++++++ test/runtime/samples/template/main.html | 3 ++ 3 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 test/runtime/samples/template/_config.js create mode 100644 test/runtime/samples/template/main.html diff --git a/src/compile/nodes/Element.ts b/src/compile/nodes/Element.ts index 12cffbbebf..a2a6f8d5b4 100644 --- a/src/compile/nodes/Element.ts +++ b/src/compile/nodes/Element.ts @@ -252,12 +252,8 @@ export default class Element extends Node { if (this.name === 'noscript') return; - const childState = { - parentNode: this.var, - parentNodes: parentNodes && block.getUniqueName(`${this.var}_nodes`) // if we're in unclaimable territory, i.e. , parentNodes is null - }; - - const name = this.var; + const node = this.var; + const nodes = parentNodes && block.getUniqueName(`${this.var}_nodes`) // if we're in unclaimable territory, i.e. , parentNodes is null const slot = this.attributes.find((attribute: Node) => attribute.name === 'slot'); const prop = slot && quotePropIfNecessary(slot.chunks[0].data); @@ -265,55 +261,55 @@ export default class Element extends Node { `${this.findNearest(/^Component/).var}._slotted${prop}` : // TODO this looks bonkers parentNode; - block.addVariable(name); + block.addVariable(node); const renderStatement = getRenderStatement(this.namespace, this.name); block.builders.create.addLine( - `${name} = ${renderStatement};` + `${node} = ${renderStatement};` ); if (this.compiler.options.hydratable) { if (parentNodes) { block.builders.claim.addBlock(deindent` - ${name} = ${getClaimStatement(compiler, this.namespace, parentNodes, this)}; - var ${childState.parentNodes} = @children(${name}); + ${node} = ${getClaimStatement(compiler, this.namespace, parentNodes, this)}; + var ${nodes} = @children(${this.name === 'template' ? `${node}.content` : node}); `); } else { block.builders.claim.addLine( - `${name} = ${renderStatement};` + `${node} = ${renderStatement};` ); } } if (initialMountNode) { block.builders.mount.addLine( - `@appendNode(${name}, ${initialMountNode});` + `@appendNode(${node}, ${initialMountNode});` ); if (initialMountNode === 'document.head') { - block.builders.destroy.addLine(`@detachNode(${name});`); + block.builders.destroy.addLine(`@detachNode(${node});`); } } else { - block.builders.mount.addLine(`@insertNode(${name}, #target, anchor);`); + block.builders.mount.addLine(`@insertNode(${node}, #target, anchor);`); // TODO we eventually need to consider what happens to elements // that belong to the same outgroup as an outroing element... - block.builders.destroy.addConditional('detach', `@detachNode(${name});`); + block.builders.destroy.addConditional('detach', `@detachNode(${node});`); } // insert static children with textContent or innerHTML if (!this.namespace && this.canUseInnerHTML && this.children.length > 0) { if (this.children.length === 1 && this.children[0].type === 'Text') { block.builders.create.addLine( - `${name}.textContent = ${stringify(this.children[0].data)};` + `${node}.textContent = ${stringify(this.children[0].data)};` ); } else { block.builders.create.addLine( - `${name}.innerHTML = ${stringify(this.children.map(toHTML).join(''))};` + `${node}.innerHTML = ${stringify(this.children.map(toHTML).join(''))};` ); } } else { this.children.forEach((child: Node) => { - child.build(block, childState.parentNode, childState.parentNodes); + child.build(block, this.name === 'template' ? `${node}.content` : node, nodes); }); } @@ -342,12 +338,12 @@ export default class Element extends Node { if (eventHandlerOrBindingUsesContext) { initialProps.push(`ctx`); - block.builders.update.addLine(`${name}._svelte.ctx = ctx;`); + block.builders.update.addLine(`${node}._svelte.ctx = ctx;`); } if (initialProps.length) { block.builders.hydrate.addBlock(deindent` - ${name}._svelte = { ${initialProps.join(', ')} }; + ${node}._svelte = { ${initialProps.join(', ')} }; `); } } else { @@ -368,9 +364,9 @@ export default class Element extends Node { block.builders.mount.addBlock(this.initialUpdate); } - if (childState.parentNodes) { + if (nodes) { block.builders.claim.addLine( - `${childState.parentNodes}.forEach(@detachNode);` + `${nodes}.forEach(@detachNode);` ); } diff --git a/test/runtime/samples/template/_config.js b/test/runtime/samples/template/_config.js new file mode 100644 index 0000000000..1346180072 --- /dev/null +++ b/test/runtime/samples/template/_config.js @@ -0,0 +1,23 @@ +export default { + // solo: 1, + + html: ` + + `, + + test(assert, component, target) { + const template = target.querySelector('template'); + + assert.htmlEqual(template.innerHTML, ` +
foo
+ `); + + const content = template.content.cloneNode(true); + const div = content.children[0]; + assert.htmlEqual(div.outerHTML, ` +
foo
+ `); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/template/main.html b/test/runtime/samples/template/main.html new file mode 100644 index 0000000000..e77230d0cc --- /dev/null +++ b/test/runtime/samples/template/main.html @@ -0,0 +1,3 @@ + \ No newline at end of file From a043c4414a8284dbdae6d69faa3c284d506c9022 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 1 Jul 2018 15:41:49 -0400 Subject: [PATCH 020/187] -> v2.9.1 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 142e7d8e30..0e494491c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Svelte changelog +## 2.9.1 + +* Use `template.content` instead of `template` where appropriate ([#1571](https://github.com/sveltejs/svelte/issues/1571)) + ## 2.9.0 * Play outro transitions on `` if `nestedTransitions` is true ([#1568](https://github.com/sveltejs/svelte/issues/1568)) diff --git a/package.json b/package.json index d619ccebcf..e0c38b4038 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "2.9.0", + "version": "2.9.1", "description": "The magical disappearing UI framework", "main": "compiler/svelte.js", "bin": { From 7cab338e32ead4acbd507a820d93d6ec6243d033 Mon Sep 17 00:00:00 2001 From: Yury Zhuravlev Date: Fri, 6 Jul 2018 19:02:12 +0900 Subject: [PATCH 021/187] Fix race condition for if block --- src/compile/dom/Block.ts | 4 ++-- src/compile/nodes/IfBlock.ts | 4 ++-- .../_config.js | 22 +++++++++++++++++++ .../main.html | 18 +++++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 test/runtime/samples/transition-js-if-block-outro-timeout/_config.js create mode 100644 test/runtime/samples/transition-js-if-block-outro-timeout/main.html diff --git a/src/compile/dom/Block.ts b/src/compile/dom/Block.ts index 977486bd8d..31a01b6eb3 100644 --- a/src/compile/dom/Block.ts +++ b/src/compile/dom/Block.ts @@ -169,9 +169,11 @@ export default class Block { toString() { const { dev } = this.compiler.options; + const properties = new CodeBuilder(); if (this.hasIntroMethod || this.hasOutroMethod) { this.addVariable('#current'); + properties.addBlock(`cr(){ return #current; },`); if (!this.builders.mount.isEmpty()) { this.builders.mount.addLine(`#current = true;`); @@ -186,8 +188,6 @@ export default class Block { this.builders.mount.addLine(`${this.autofocus}.focus();`); } - const properties = new CodeBuilder(); - let localKey; if (this.key) { localKey = this.getUniqueName('key'); diff --git a/src/compile/nodes/IfBlock.ts b/src/compile/nodes/IfBlock.ts index 730128fc71..cac0c78d4b 100644 --- a/src/compile/nodes/IfBlock.ts +++ b/src/compile/nodes/IfBlock.ts @@ -301,7 +301,7 @@ export default class IfBlock extends Node { const updateMountNode = this.getUpdateMountNode(anchor); const destroyOldBlock = deindent` - @groupOutros(); + if(${name}.cr()) @groupOutros(); ${name}.o(function() { ${if_blocks}[${previous_block_index}].d(1); ${if_blocks}[${previous_block_index}] = null; @@ -423,7 +423,7 @@ export default class IfBlock extends Node { // as that will typically result in glitching const exit = branch.hasOutroMethod ? deindent` - @groupOutros(); + if(${name}.cr()) @groupOutros(); ${name}.o(function() { ${name}.d(1); ${name} = null; diff --git a/test/runtime/samples/transition-js-if-block-outro-timeout/_config.js b/test/runtime/samples/transition-js-if-block-outro-timeout/_config.js new file mode 100644 index 0000000000..cacc88669d --- /dev/null +++ b/test/runtime/samples/transition-js-if-block-outro-timeout/_config.js @@ -0,0 +1,22 @@ +export default { + test ( assert, component, target, window, raf ) { + component.set({ visible: true }); + const div = target.querySelector('div'); + + component.set({ visible: false }); + assert.equal(window.getComputedStyle(div).opacity, 1); + + raf.tick(200); + assert.equal(window.getComputedStyle(div).opacity, 0.5); + component.set({ blabla: false }); + + raf.tick(400); + assert.equal(window.getComputedStyle(div).opacity, 0); + + raf.tick(600); + assert.equal(component.refs.div, undefined); + assert.equal(target.querySelector('div'), undefined); + + component.destroy(); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/transition-js-if-block-outro-timeout/main.html b/test/runtime/samples/transition-js-if-block-outro-timeout/main.html new file mode 100644 index 0000000000..7b627a9f72 --- /dev/null +++ b/test/runtime/samples/transition-js-if-block-outro-timeout/main.html @@ -0,0 +1,18 @@ +{#if visible} +
yes
+{/if} + + \ No newline at end of file From 2edc56b91996288f1a86c3fe409d8e3d85dc7e8f Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 6 Jul 2018 09:25:38 -0400 Subject: [PATCH 022/187] :us: --- src/cli/error.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli/error.ts b/src/cli/error.ts index b7ca813716..cfe6a3e72d 100644 --- a/src/cli/error.ts +++ b/src/cli/error.ts @@ -8,9 +8,9 @@ export default function error(err) { stderr(`${clorox.red(err.message || err)}`); if (err.frame) { - stderr(err.frame); // eslint-disable-line no-console + stderr(err.frame); } else if (err.stack) { - stderr(`${clorox.grey(err.stack)}`); + stderr(`${clorox.gray(err.stack)}`); } process.exit(1); From 909536dac9c8597af93dac1f9c3d99b47d784087 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 8 Jul 2018 01:47:38 -0400 Subject: [PATCH 023/187] fix determing whether an attribute should prevent innerHTML optimization Fixes #1581 --- src/compile/nodes/Element.ts | 8 +++++++- .../samples/attribute-dynamic-no-dependencies/_config.js | 5 +++++ .../samples/attribute-dynamic-no-dependencies/main.html | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/attribute-dynamic-no-dependencies/_config.js create mode 100644 test/runtime/samples/attribute-dynamic-no-dependencies/main.html diff --git a/src/compile/nodes/Element.ts b/src/compile/nodes/Element.ts index a2a6f8d5b4..403b9cce8b 100644 --- a/src/compile/nodes/Element.ts +++ b/src/compile/nodes/Element.ts @@ -152,8 +152,14 @@ export default class Element extends Node { ); this.attributes.forEach(attr => { - if (attr.dependencies.size) { + if ( + attr.chunks && + attr.chunks.length && + (attr.chunks.length > 1 || attr.chunks[0].type !== 'Text') + ) { this.parent.cannotUseInnerHTML(); + } + if (attr.dependencies.size) { block.addDependencies(attr.dependencies); // special case —