ember-inspector icon indicating copy to clipboard operation
ember-inspector copied to clipboard

Fix value.hasOwnProperty is not a function error

Open gitKrystan opened this issue 4 months ago • 6 comments

Description

I keep running into this error when value is a proxy. With this change, it works even w/ proxies.

TBH I didn't really look at what the point of this code is so IDK if this fix is correct. I just want it to stop borking my debug sessions. 😂

Screenshots

image

gitKrystan avatar Jul 25 '25 23:07 gitKrystan

should maybe guard against null too, IDK. Don't think I've run into null here yet

gitKrystan avatar Jul 25 '25 23:07 gitKrystan

This part of code is used to display object information in inspector object side panel. Basically a subset of key/value pairs gets shown for pure objects It's shows a subset of object keys for performance.

patricklx avatar Jul 26 '25 05:07 patricklx

I do not see any issues with this. But maybe could add a test? https://github.com/emberjs/ember-inspector/blob/main/tests/unit/utils/type-check-test.js

patricklx avatar Jul 26 '25 05:07 patricklx

Should also check when looking at component args

patricklx avatar Jul 26 '25 08:07 patricklx

I don't actually have the repo cloned or the time to write a test ATM but this appears to be the minimal repro:

const foo = new Proxy(
  {},
  {
    get(_target, prop) {
      return null;
    },
  }
);
foo.hasOwnProperty; // null

gitKrystan avatar Jul 28 '25 23:07 gitKrystan

@gitKrystan I do not have access to push something, add this tests to tests/unit/utils/type-check-test.js

test('inspect | works with proxy', async function (assert) {
    let inspected = new Proxy(
      {},
      {
        get() {
          return null;
        },
      },
    );

    let obj = inspect(inspected);

    assert.deepEqual(obj, '{  }', 'object is in expected shape');
  });

  test('inspect | works with Object.create null proto', async function (assert) {
    let inspected = Object.create(null);

    let obj = inspect(inspected);

    assert.deepEqual(obj, '{  }', 'object is in expected shape');
  });

patricklx avatar Oct 06 '25 08:10 patricklx