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

Watch being fired for a different property when the value is changed #4090

Closed
doonetheprune opened this issue Nov 2, 2016 · 8 comments
Closed

Comments

@doonetheprune
Copy link

doonetheprune commented Nov 2, 2016

Hi

I have come across a strange issue where the watch for a property is called when the property has a default value of an empty object and the value property is changed. If that makes no sense, I have created a js fiddle to demonstrate it.

https://jsfiddle.net/rdjjpc7a/90/

@defcc
Copy link
Member

defcc commented Nov 2, 2016

The same with #4060 . When re-render, the default function of nuts returns an object literal {}.

@defcc defcc added the 2.0 label Nov 2, 2016
@defcc defcc closed this as completed Nov 2, 2016
@doonetheprune
Copy link
Author

Hi

I don't think the two issues are the same as I am not changing the 'nuts' property and the watch is still being fired.

@defcc
Copy link
Member

defcc commented Nov 2, 2016

@doonetheprune , your nuts prop default function will return a fresh object {} each time, {} !== {}, it's changed internally.

@doonetheprune
Copy link
Author

@defcc I agree the default function should return a fresh object however I don't think it should return a new object every time the value property is changed, it should only do it when the component is created. If you look at fiddle the nuts property should not be affected by the value property.

Please could you reopen as this is not the same as #4060?

@defcc
Copy link
Member

defcc commented Nov 2, 2016

This is caused by the vue2 render system.
When input value changed, your app rerenders from top to bottom, the bla component is also affected.

I add a updated function to your demo for a better understanding. https://jsfiddle.net/rdjjpc7a/92/

@doonetheprune
Copy link
Author

@defcc how come then if the nuts property is a string why is the watch not fired?

https://jsfiddle.net/rdjjpc7a/93/

@defcc
Copy link
Member

defcc commented Nov 2, 2016

explained here , you could take a look.

@doonetheprune
Copy link
Author

@defcc I have looked at the fiddle in #4060 and can see why they are similar and the underlying issue might be the same. This issue however highlights the problem in a scenario that is a lot more likely to occur. Also reading the comments from @yyx990803 on issue #4060 it makes me really worried you dont plan on fixing this issue. Without trying to be to harsh on vue which I think is great, a basic bug like this means it looses a lot of credibility. If I came across this when I first started using vue I would have stopped using it.

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

No branches or pull requests

3 participants