From: Eduardo San Martin Morote Date: Mon, 29 Mar 2021 17:07:59 +0000 (+0200) Subject: fix: use assign instead of spread X-Git-Tag: v2.0.0-alpha.8~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b2bb5ba4faf52c41479a7d77490b85016b853229;p=thirdparty%2Fvuejs%2Fpinia.git fix: use assign instead of spread Support old browsers like Edge 17 or Firefox 52 --- diff --git a/src/store.ts b/src/store.ts index 13fa213b..4b6a2a4a 100644 --- a/src/store.ts +++ b/src/store.ts @@ -42,6 +42,8 @@ function innerPatch( return target } +const { assign } = Object + /** * Create an object of computed properties referring to * @@ -206,21 +208,21 @@ function buildStoreToUse< } const extensions = pinia._p.reduce( - (extended, extender) => ({ - ...extended, - ...extender(), - }), + (extended, extender) => assign({}, extended, extender()), {} as PiniaCustomProperties ) - const store: Store = reactive({ - ...extensions, - ...partialStore, - // using this means no new properties can be added as state - ...computedFromState(pinia.state, $id), - ...computedGetters, - ...wrappedActions, - }) as Store + const store: Store = reactive( + assign( + {}, + extensions, + partialStore, + // using this means no new properties can be added as state + computedFromState(pinia.state, $id), + computedGetters, + wrappedActions + ) + ) as Store // use this instead of a computed with setter to be able to create it anywhere // without linking the computed lifespan to wherever the store is first