refactor(reactive): reduce code size by assigning to a local variable (#1634)
This commit is contained in:
parent
fb8e83f0c2
commit
3e412c10e0
@ -141,12 +141,11 @@ function createReactiveObject(
|
|||||||
return target
|
return target
|
||||||
}
|
}
|
||||||
// target already has corresponding Proxy
|
// target already has corresponding Proxy
|
||||||
if (
|
const reactiveFlag = isReadonly
|
||||||
hasOwn(target, isReadonly ? ReactiveFlags.READONLY : ReactiveFlags.REACTIVE)
|
? ReactiveFlags.READONLY
|
||||||
) {
|
: ReactiveFlags.REACTIVE
|
||||||
return isReadonly
|
if (hasOwn(target, reactiveFlag)) {
|
||||||
? target[ReactiveFlags.READONLY]
|
return target[reactiveFlag]
|
||||||
: target[ReactiveFlags.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)) {
|
||||||
@ -156,11 +155,7 @@ function createReactiveObject(
|
|||||||
target,
|
target,
|
||||||
collectionTypes.has(target.constructor) ? collectionHandlers : baseHandlers
|
collectionTypes.has(target.constructor) ? collectionHandlers : baseHandlers
|
||||||
)
|
)
|
||||||
def(
|
def(target, reactiveFlag, observed)
|
||||||
target,
|
|
||||||
isReadonly ? ReactiveFlags.READONLY : ReactiveFlags.REACTIVE,
|
|
||||||
observed
|
|
||||||
)
|
|
||||||
return observed
|
return observed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user