[fix] Spread component props immutably during SSR (#8176)

By passing an empty object literal as first argument to Object.assign we can avoid having objects spread as props on a component being mutated during SSR.

Fixes #8171
pull/8190/head
Emil Tholin 2 years ago committed by GitHub
parent aa98397440
commit b06e435684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -36,7 +36,7 @@ export default function(node: InlineComponent, renderer: Renderer, options: Rend
let props;
if (uses_spread) {
props = x`@_Object.assign(${
props = x`@_Object.assign({}, ${
node.attributes
.map(attribute => {
if (attribute.is_spread) {

@ -0,0 +1,15 @@
const obj = {
x: 1,
y: 2,
z: 3
};
export default {
props: {
obj
},
test({ assert }) {
assert.deepEqual(obj, { x: 1, y: 2, z: 3 });
}
};

@ -0,0 +1,7 @@
<script>
import Widget from './Widget.svelte';
export let obj;
</script>
<Widget {...obj} x={2} />
Loading…
Cancel
Save