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

When a getter is defined that does not define a setter, no recursive reactive is made. #8494

Open
ts0307 opened this issue Jul 16, 2018 · 4 comments

Comments

@ts0307
Copy link

ts0307 commented Jul 16, 2018

Version

2.5.17-beta.0

Reproduction link

https://jsfiddle.net/ts0307/pd8zr3sk/

Steps to reproduce

Run JSFiddle snippet

What is expected?

I expect, the result is shown as {"bar": "b"} instead of {"bar": "a"}

What is actually happening?

if ((!getter || setter) && arguments.length === 2) {
val = obj[key]
}

let childOb = !shallow && observe(val)

My example is that the data object defines that the getter does not define a setter, causing the above judgment to fail, val is not evaluated, and no recursive reactive is made.

@pkaminski
Copy link
Contributor

FYI: Ignoring getters was done on purpose due to #7280. I added an exception for getter/setter pairs in #7828 to fix my own use case. I don't know whether ignoring pure getters is right or not, but either way it's clear that somebody will be unhappy.

@ts0307
Copy link
Author

ts0307 commented Jul 16, 2018

It seems that it is difficult to be compatible with all use cases.

@malaxiannv
Copy link

@ts0307 if a getter is defined, proving that the property is an accessor property. If an accessor property does not have a setter, that means the property cannot be set new Value, thus there is no need to make it be recursive reactive.

@shengrongchun
Copy link

why not?
let childOb = !shallow && observe(val) -->
get: function reactiveGetter () { const value = getter ? getter.call(obj) : val; childOb = !shallow && observe(value);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants