8000 fix(useIDBKeyval): use toRaw instead of overriding the original objec… · vueuse/vueuse@1b67d96 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 1b67d96

Browse files
authored
fix(useIDBKeyval): use toRaw instead of overriding the original object (#3805)
Signed-off-by: GitHub <noreply@github.com>
1 parent ee2977b commit 1b67d96

File tree

1 file changed

+2
-7
lines changed
  • packages/integrations/useIDBKeyval

1 file changed

+2
-7
lines changed

packages/integrations/useIDBKeyval/index.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ConfigurableFlush, MaybeRefOrGetter, RemovableRef } from '@vueuse/
22
import { toValue } from '@vueuse/shared'
33
import { watchPausable } from '@vueuse/core'
44
import type { Ref } from 'vue-demi'
5-
import { ref, shallowRef } from 'vue-demi'
5+
import { ref, shallowRef, toRaw } from 'vue-demi'
66
import { del, get, set, update } from 'idb-keyval'
77

88
export interface UseIDBOptions extends ConfigurableFlush {
@@ -92,12 +92,7 @@ export function useIDBKeyval<T>(
9292
}
9393
else {
9494
// IndexedDB does not support saving proxies, convert from proxy before saving
95-
if (Array.isArray(data.value))
96-
await update(key, () => (JSON.parse(JSON.stringify(data.value))))
97-
else if (typeof data.value === 'object')
98-
await update(key, () => ({ ...data.value }))
99-
else
100-
await update(key, () => (data.value))
95+
await update(key, () => toRaw(data.value))
10196
}
10297
}
10398
catch (e) {

0 commit comments

Comments
 (0)
0