From e67940f7e041e598c6bc58d7784fe4ccaa975f2c Mon Sep 17 00:00:00 2001 From: Caleb Hearon Date: Fri, 13 Aug 2021 22:23:02 -0400 Subject: [PATCH] fix: don't invoke Vue getters in setter (#786) Fixes #498 --- src/reactivity/reactive.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/reactivity/reactive.ts b/src/reactivity/reactive.ts index 7599ab68..d08b7c5b 100644 --- a/src/reactivity/reactive.ts +++ b/src/reactivity/reactive.ts @@ -94,14 +94,14 @@ export function defineAccessControl(target: AnyObject, key: any, val?: any) { set: function setterHandler(newVal: any) { if (getter && !setter) return - const value = getter ? getter.call(target) : val // If the key is equal to RefKey, skip the unwrap logic // If and only if "value" is ref and "newVal" is not a ref, // the assignment should be proxied to "value" ref. - if (key !== RefKey && isRef(value) && !isRef(newVal)) { - value.value = newVal + if (key !== RefKey && isRef(val) && !isRef(newVal)) { + val.value = newVal } else if (setter) { setter.call(target, newVal) + val = newVal } else { val = newVal }