refactor(reactivity): define hadKey if necessary (#288)

This commit is contained in:
edison 2019-10-15 23:59:40 +08:00 committed by Evan You
parent 4cee06ddab
commit b5209277de

View File

@ -38,12 +38,12 @@ function set(
receiver: any
): boolean {
value = toRaw(value)
const hadKey = hasOwn(target, key)
const oldValue = target[key]
if (isRef(oldValue) && !isRef(value)) {
oldValue.value = value
return true
}
const hadKey = hasOwn(target, key)
const result = Reflect.set(target, key, value, receiver)
// don't trigger if target is something up in the prototype chain of original
if (target === toRaw(receiver)) {