Skip to content

Commit

Permalink
feat: Unified as the key of raw in vue3 (#922)
Browse files Browse the repository at this point in the history
Co-authored-by: neiyichao03 <nieyichao03@kuaishou.com>
  • Loading branch information
edwardnyc and neiyichao03 committed Apr 23, 2022
1 parent 000ffe4 commit 5874eb5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/reactivity/reactive.ts
Expand Up @@ -16,12 +16,14 @@ import { isRef, UnwrapRef } from './ref'
import { rawSet, accessModifiedSet } from '../utils/sets'
import { isForceTrigger } from './force'

const SKIPFLAG = '__v_skip'

export function isRaw(obj: any): boolean {
return Boolean(
obj &&
hasOwn(obj, '__ob__') &&
typeof obj.__ob__ === 'object' &&
obj.__ob__?.__raw__
obj.__ob__?.[SKIPFLAG]
)
}

Expand All @@ -30,7 +32,7 @@ export function isReactive(obj: any): boolean {
obj &&
hasOwn(obj, '__ob__') &&
typeof obj.__ob__ === 'object' &&
!obj.__ob__?.__raw__
!obj.__ob__?.[SKIPFLAG]
)
}

Expand Down Expand Up @@ -261,7 +263,7 @@ export function markRaw<T extends object>(obj: T): T {

// set the vue observable flag at obj
const ob = createObserver()
ob.__raw__ = true
ob[SKIPFLAG] = true
def(obj, '__ob__', ob)

// mark as Raw
Expand Down

0 comments on commit 5874eb5

Please sign in to comment.