firefox-devtools / devtools-core

:rocket: Packages for Firefox DevTools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Show <prototype> even if it's null

Loirooriol opened this issue · comments

If I have an object whose [[Prototype]] is null the object inspector does not show <prototype>. This case can be confused with objects whose prototype chain is not known, e.g. proxies. So I would make it explicit and not hide the <prototype> even if it's null. Also consider this case:

var obj = Object.create(null);
obj.__proto__ = Object.prototype;
inspect(obj);

Someone might be confused by the __proto__ property and think that the object inherits from Object.prototype.

  ▼ {...}
  | ▶ __proto__: Object { … }

I think this would be clearer:

  ▼ {...}
  | ▶ __proto__: Object { … }
  |   <prototype>: null

I believe changing this conditional would do the trick:

https://github.com/devtools-html/devtools-core/blob/43aa5cfa37703024a6c0a5fb46a507560385004f/packages/devtools-reps/src/object-inspector/utils/node.js#L595-L596

Yes, this could be interesting, thanks for filing