-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Computed property setter on component other than "this" not called when updating v-model #6908
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
Comments
I've found a change in parseModel which might be the culprit. Prior to this change, v-model bindings in the form 'foo.bar' would not be rewritten to '$set(foo, 'bar', $$v)'. |
Either way using |
I understand. However, my reproducible isn't really reflective of what I'm trying to accomplish. I have written a simple data grid, which accepts arbitrary Vue template strings to render column contents with. For the header column, I'm rendering a checkbox whose data is to be bound to a computed property on the containing component (the one that instantiates the data grid). This checkbox reflect the selected state of all rows in the grid, and changing should update the underlying selection flags on each of the rows. I've implemented this by declaring a method findParent via a global mixin, which looks for the offending parent component, and then accessing the computed property like so:
Prior to 2.5.0 this worked nicely; however, when updating to 2.5.2 this code broke. I do have a workaround: turning the computed property in question into a data property, and using a watch to sync its value with the individual selection flags. But that's hardly ideal. |
This is coincidentally fixed in 83ed926 |
Version
2.5.2
Reproduction link
http://jsfiddle.net/pLvn7o95/
Steps to reproduce
What is expected?
The computed property setter is called.
What is actually happening?
The computed property setter is not called and the following message appears in the JavaScript console:
[Vue warn]: Avoid adding reactive properties to a Vue instance or its root $data at runtime - declare it upfront in the data option.
This appears to be a regression in Vue 2.5.0, as changing the Vue version in the provided jsFiddle to 2.4.0 fixes the bug. The optimisation applied earlier in the 2.x-series to declare computed properties on the component's prototype appears to interfere with the call to hasOwn in function set (in observer/index).
The text was updated successfully, but these errors were encountered: