Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Unified as the key of raw in vue3 #922

Merged
merged 1 commit into from Apr 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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