Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't invoke Vue getters in setter #786

Merged
merged 1 commit into from Aug 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/reactivity/reactive.ts
Expand Up @@ -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
}
Expand Down