Skip to content

Commit a405fc8

Browse files
committed
fix: don't invoke Vue getters in setter
Fixes #498
1 parent 1b63186 commit a405fc8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/reactivity/reactive.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ export function defineAccessControl(target: AnyObject, key: any, val?: any) {
9494
set: function setterHandler(newVal: any) {
9595
if (getter && !setter) return
9696

97-
const value = getter ? getter.call(target) : val
9897
// If the key is equal to RefKey, skip the unwrap logic
9998
// If and only if "value" is ref and "newVal" is not a ref,
10099
// the assignment should be proxied to "value" ref.
101-
if (key !== RefKey && isRef(value) && !isRef(newVal)) {
102-
value.value = newVal
100+
if (key !== RefKey && isRef(val) && !isRef(newVal)) {
101+
val.value = newVal
103102
} else if (setter) {
104103
setter.call(target, newVal)
104+
val = newVal
105105
} else {
106106
val = newVal
107107
}

0 commit comments

Comments
 (0)