Skip to content

Watch triggered on unchanged NaN value #4236

Closed

Description

@amichair

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.

Activity

  1. amichair commented on Nov 18, 2016

    @amichair
    Author

    Thanks for the really quick response and fix!

  2. kongweigen commented on Nov 1, 2021

    @kongweigen

    get

  3. YuFengjie97 commented on Nov 9, 2022

    @YuFengjie97

    į‰›é€ž

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions