Skip to content

diffJson throws on Object.create(null) in some cases #492

@danbeam

Description

@danbeam

Minimal repro:

diffJson(Object.assign(Object.create(null), {a: 123}), {b: 456});

With an error like:

/.../node_modules/diff/src/diff/json.js:68
      if (obj.hasOwnProperty(key)) {
              ^
TypeError: obj.hasOwnProperty is not a function

As far as I can tell, some popular libraries export object with these setups (e.g. eslint and express). I believe I have a simple fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions