Skip to content

Commit

Permalink
fix(reactivity): check skip first before checking ref when creating o…
Browse files Browse the repository at this point in the history
…bserver (#12813)

fix #12812
  • Loading branch information
xiersa committed Oct 11, 2022
1 parent 4a0d88e commit 5d26f81
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/core/observer/index.ts
Expand Up @@ -7,7 +7,6 @@ import {
hasOwn,
isArray,
hasProto,
isObject,
isPlainObject,
isPrimitive,
isUndef,
Expand Down Expand Up @@ -108,23 +107,21 @@ export function observe(
shallow?: boolean,
ssrMockReactivity?: boolean
): Observer | void {
if (!isObject(value) || isRef(value) || value instanceof VNode) {
return
if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
return value.__ob__
}
let ob: Observer | void
if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
ob = value.__ob__
} else if (
if (
shouldObserve &&
(ssrMockReactivity || !isServerRendering()) &&
(isArray(value) || isPlainObject(value)) &&
Object.isExtensible(value) &&
!value.__v_skip /* ReactiveFlags.SKIP */ &&
!rawMap.has(value)
!rawMap.has(value) &&
!isRef(value) &&
!(value instanceof VNode)
) {
ob = new Observer(value, shallow, ssrMockReactivity)
return new Observer(value, shallow, ssrMockReactivity)
}
return ob
}

/**
Expand Down

0 comments on commit 5d26f81

Please sign in to comment.