Skip to content

Commit

Permalink
refactor: remove old code
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Nov 22, 2024
1 parent 94100dc commit 49d4155
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions packages/pinia/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ function mergeReactiveObjects<
const skipHydrateSymbol = __DEV__
? Symbol('pinia:skipHydration')
: /* istanbul ignore next */ Symbol()
const skipHydrateMap = /*#__PURE__*/ new WeakMap<any, any>()

/**
* Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a
Expand All @@ -127,12 +126,7 @@ const skipHydrateMap = /*#__PURE__*/ new WeakMap<any, any>()
* @returns obj
*/
export function skipHydrate<T = any>(obj: T): T {
// TODO: check if can be simplified for Vue 2.7
return isVue2
? // in @vue/composition-api (no needed in Vue 2.7),
// the refs are sealed so defineProperty doesn't work...
/* istanbul ignore next */ skipHydrateMap.set(obj, 1) && obj
: Object.defineProperty(obj, skipHydrateSymbol, {})
return Object.defineProperty(obj, skipHydrateSymbol, {})
}

/**
Expand All @@ -142,9 +136,7 @@ export function skipHydrate<T = any>(obj: T): T {
* @returns true if `obj` should be hydrated
*/
export function shouldHydrate(obj: any) {
return isVue2
? /* istanbul ignore next */ !skipHydrateMap.has(obj)
: !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol)
return !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol)
}

const { assign } = Object
Expand Down

0 comments on commit 49d4155

Please sign in to comment.