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 {
|
import {
|
||||||
mutableHandlers,
|
mutableHandlers,
|
||||||
readonlyHandlers,
|
readonlyHandlers,
|
||||||
@ -116,18 +116,19 @@ function createReactiveObject(
|
|||||||
return target
|
return target
|
||||||
}
|
}
|
||||||
// target already has corresponding Proxy
|
// target already has corresponding Proxy
|
||||||
let observed = isReadonly ? target.__v_readonly : target.__v_reactive
|
if (
|
||||||
if (observed !== void 0) {
|
hasOwn(target, isReadonly ? ReactiveFlags.readonly : ReactiveFlags.reactive)
|
||||||
return observed
|
) {
|
||||||
|
return isReadonly ? target.__v_readonly : target.__v_reactive
|
||||||
}
|
}
|
||||||
// only a whitelist of value types can be observed.
|
// only a whitelist of value types can be observed.
|
||||||
if (!canObserve(target)) {
|
if (!canObserve(target)) {
|
||||||
return target
|
return target
|
||||||
}
|
}
|
||||||
const handlers = collectionTypes.has(target.constructor)
|
const observed = new Proxy(
|
||||||
? collectionHandlers
|
target,
|
||||||
: baseHandlers
|
collectionTypes.has(target.constructor) ? collectionHandlers : baseHandlers
|
||||||
observed = new Proxy(target, handlers)
|
)
|
||||||
def(
|
def(
|
||||||
target,
|
target,
|
||||||
isReadonly ? ReactiveFlags.readonly : ReactiveFlags.reactive,
|
isReadonly ? ReactiveFlags.readonly : ReactiveFlags.reactive,
|
||||||
|
Loading…
Reference in New Issue
Block a user