fix(reactivity): check own property for existing proxy of target
fix #1107
This commit is contained in:
parent
8bab78b648
commit
6be2b73f8a
@ -1,4 +1,4 @@
|
||||
import { isObject, toRawType, def } from '@vue/shared'
|
||||
import { isObject, toRawType, def, hasOwn } from '@vue/shared'
|
||||
import {
|
||||
mutableHandlers,
|
||||
readonlyHandlers,
|
||||
@ -116,18 +116,19 @@ function createReactiveObject(
|
||||
return target
|
||||
}
|
||||
// target already has corresponding Proxy
|
||||
let observed = isReadonly ? target.__v_readonly : target.__v_reactive
|
||||
if (observed !== void 0) {
|
||||
return observed
|
||||
if (
|
||||
hasOwn(target, isReadonly ? ReactiveFlags.readonly : ReactiveFlags.reactive)
|
||||
) {
|
||||
return isReadonly ? target.__v_readonly : target.__v_reactive
|
||||
}
|
||||
// only a whitelist of value types can be observed.
|
||||
if (!canObserve(target)) {
|
||||
return target
|
||||
}
|
||||
const handlers = collectionTypes.has(target.constructor)
|
||||
? collectionHandlers
|
||||
: baseHandlers
|
||||
observed = new Proxy(target, handlers)
|
||||
const observed = new Proxy(
|
||||
target,
|
||||
collectionTypes.has(target.constructor) ? collectionHandlers : baseHandlers
|
||||
)
|
||||
def(
|
||||
target,
|
||||
isReadonly ? ReactiveFlags.readonly : ReactiveFlags.reactive,
|
||||
|
Loading…
Reference in New Issue
Block a user