Fix value.hasOwnProperty is not a function error
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
should maybe guard against null too, IDK. Don't think I've run into null here yet
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.
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
Should also check when looking at component args
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 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');
});