Merge pull request #1283 from sveltejs/assign-fix

fix assembly of initial state object
pull/1288/head
Rich Harris 7 years ago committed by GitHub
commit af7ef12b4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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);`}

@ -0,0 +1,7 @@
export default {
data: { bar: 'bar' },
html: `
"foo"
"bar"
`,
};

@ -0,0 +1,10 @@
{{JSON.stringify(foo)}}
{{JSON.stringify(bar)}}
<script>
export default {
data() {
return { foo: 'foo' };
}
};
</script>
Loading…
Cancel
Save