Skip to content

Watch triggered on unchanged NaN value #4236

Closed
@amichair

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.

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