Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.
This repository was archived by the owner on May 14, 2020. It is now read-only.

Error objects cannot be expanded + Fix for #20 #22

@skleeschulte

Description

@skleeschulte

Error objects in the state tree cannot be expanded. Thats because iterating with for...in and hasOwnProperty doesn't work here. However this should easily be fixed by adding this before line 30 in JSONObjectNode.js:

if (data instanceof Error) {
    data = Object.getOwnPropertyNames(data).reduce(function (errorObj, prop) {
        errorObj[prop] = data[prop];
        return errorObj;
    }, {});
}

In addition, to solve Objects without prototype chain are broken #20 , line 32 in JSONObjectNode.js could be changed to:

if (Object.getPrototypeOf(data) === null || data.hasOwnProperty(key)) {

(IMHO thats better than PR Fixes #20, expanding of objects without prototype #21.)

I would create a pull request, but I cannot test this, because I cannot build the package. (I cloned it from github, but get lot's of errors on npm install, npm build and npm run lint. Even after fixing npm install and npm build (by removing all the carets from the dependency versions in package.json and installing [email protected]), with npm build the output in lib looks different from what I get from npm install react-json-tree.)

But I'm sure someone can do it. :)

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