From 5dcbb8881bc8d2c991ff3f80f2611cb2a62e8431 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Wed, 28 Mar 2018 06:30:47 -0400 Subject: [PATCH 1/2] fix assembly of initial state object --- src/generators/dom/index.ts | 2 +- test/runtime/samples/initial-state-assign/_config.js | 7 +++++++ test/runtime/samples/initial-state-assign/main.html | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/initial-state-assign/_config.js create mode 100644 test/runtime/samples/initial-state-assign/main.html diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index 6f06ded60b..e6390bb572 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -202,7 +202,7 @@ export default function dom( @init(this, options); ${templateProperties.store && `this.store = %store();`} ${generator.usesRefs && `this.refs = {};`} - this._state = @assign(${initialState.join(', ')}); + this._state = ${initialState.reduce((state, piece) => `@assign(${state}, ${piece})`)}; ${storeProps.length > 0 && `this.store._add(this, [${storeProps.map(prop => `"${prop.slice(1)}"`)}]);`} ${generator.metaBindings} ${computations.length && `this._recompute({ ${Array.from(computationDeps).map(dep => `${dep}: 1`).join(', ')} }, this._state);`} diff --git a/test/runtime/samples/initial-state-assign/_config.js b/test/runtime/samples/initial-state-assign/_config.js new file mode 100644 index 0000000000..961cffae43 --- /dev/null +++ b/test/runtime/samples/initial-state-assign/_config.js @@ -0,0 +1,7 @@ +export default { + data: { bar: 'bar' }, + html: ` + "foo" + "bar" + `, +}; diff --git a/test/runtime/samples/initial-state-assign/main.html b/test/runtime/samples/initial-state-assign/main.html new file mode 100644 index 0000000000..5c9f1826a0 --- /dev/null +++ b/test/runtime/samples/initial-state-assign/main.html @@ -0,0 +1,10 @@ +{{JSON.stringify(foo)}} +{{JSON.stringify(bar)}} + + From 7ee9d9ad94642731e0315d5a80bfee4520c114e1 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Wed, 28 Mar 2018 08:45:09 -0400 Subject: [PATCH 2/2] -> v1.58.4 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1210acddeb..d08340d187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Svelte changelog +## 1.58.4 + +* Fix initial state regression ([#1283](https://github.com/sveltejs/svelte/pull/1283)) + ## 1.58.3 * Actions run in the context of the component ([#1279](https://github.com/sveltejs/svelte/pull/1279)) diff --git a/package.json b/package.json index 61195c1913..1d96933f2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "1.58.3", + "version": "1.58.4", "description": "The magical disappearing UI framework", "main": "compiler/svelte.js", "files": [