From 7b6f2060030277e080e6285ff1c6d9df1e42b658 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Wed, 28 Mar 2018 06:30:47 -0400 Subject: [PATCH] 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)}} + +