Skip to content

areEqual doesn't support objects with null prototypes #416

@p7g

Description

@p7g

In areEqual, there is a branch where the valueOf both objects is compared if supported, but the check for if it's supported raises an exception if the objects don't have the Object prototype.

Specifically, since it does a.hasOwnProperty("valueOf"), if a doesn't have a hasOwnProperty method it will fail.

It's possible the solution would be to use Object.hasOwnProperty.call(a, "valueOf") instead, but I'm not clear on any semantic differences there might be. If that's acceptable, I can open a pull request.


For some context, I ran into this issue when passing a value from another library to Relay's RecordProxy.setValue. That other library happens to create some objects like Object.create(null).

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