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 triggered on unchanged NaN value #4236

Closed
amichair opened this issue Nov 17, 2016 · 3 comments
Closed

Watch triggered on unchanged NaN value #4236

amichair opened this issue Nov 17, 2016 · 3 comments

Comments

@amichair
Copy link

amichair commented Nov 17, 2016

When a watched object's property has a NaN value and is then set again to NaN, the watch callback is incorrectly triggered. In my application this results in an infinite loop (the watch callback does some calculations on the object, which sets the NaN back to NaN).

The issue is with the reactive setter comparison of old and new value, since one of the many JS quirks is that NaN === NaN is always false. changing
if (newVal === value) {
to
if (newVal === value || newVal !== newVal && value !== value) { // accounts for NaN quirks
solves the issue.

@amichair
Copy link
Author

Thanks for the really quick response and fix!

@kongweigen
Copy link

get

@YuFengjie97
Copy link

牛逼

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