update: merge props with state objects

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-11-19 02:44:48 +01:00
parent 5e399a6cc1
commit 48da1eccba

View File

@@ -105,7 +105,11 @@ const { store, hooks } = initFlow(emit, props)
const init = (opts: typeof props) => {
for (const opt of Object.keys(opts)) {
const val = opts[opt as keyof FlowProps]
if (val && typeof val !== 'undefined') (store.$state as any)[opt] = val
if (val && typeof val !== 'undefined') {
if (typeof val === 'object' && !Array.isArray(val)) {
;(store.$state as any)[opt] = { ...(store.$state as any)[opt], ...val }
} else (store.$state as any)[opt] = val
}
}
store.setElements(store.elements)
store.setMinZoom(opts.minZoom)