Eric J. Van der Velden | 16 Mar 2012 20:15
Picon
Gravatar

Re: Node's __proto__

On Mar 12, 7:00 am, Bobby Holley <bobbyhol... <at> gmail.com> wrote:
> Hi Eric,
>
> |Node| and |Element| are both constructor objects. They both have the same
> proto, and it's very uninteresting (the proto of that object is
> Object.prototype).
>
> Things like |Node| and |Element| are just kind of waystations on the way to
> things like Node.prototype and Element.prototype. Those are the __proto__s
> for actual Node and Element instances, and they form a nice inheritance
> hierarchy (ie: Element.prototype.__proto__ === Node.prototype).
>
> But we also do a lot of that stuff wrong in Gecko, as it stands. For
> example, each prototype has a flattened version of all methods and
> properties it inherits. But we're fixing this all soon.
>
> Cheers,
> bholley
>
> On Sun, Mar 11, 2012 at 6:49 AM, Eric J. Van der Velden <
>
>
>
>
>
>
>
> ericjvandervel... <at> gmail.com> wrote:
> > Hello,
>
(Continue reading)

Boris Zbarsky | 16 Mar 2012 20:30
Picon
Favicon

Re: Node's __proto__

On 3/16/12 3:15 PM, Eric J. Van der Velden wrote:
> I understand for example that
> Node.prototype.__proto__===Object.prototype, but although
> uninteresting, I still would like to know what I should write on
> the ... in Node.__proto__===....prototype.

Per future specs, Node.__proto__ === Function.prototype, since Node is a 
Function object.

In Gecko's current implementation, it depends.  In the new DOM bindings, 
the interface object's proto should be Function.prototype.  In the 
XPConnect bindings (which Node is at the moment, but hopefully not for 
much longer), I have no idea offhand.

> Because Object is a function, Object.__proto__===Function.prototype.
> So I thought: Function.__proto__===Function.prototype. I thought
> Function in JavaScript similar to Object in Java. But it is not true.

Function.__proto__ === Function.prototype, yes.

Node is special, because it's actually a host object at the moment.

> Also what do you mean by "each prototype has a flattened version of
> all methods and properties it inherits"?

That wasn't relevant to your question; it was about Node.prototype.

-Boris
Eric J. Van der Velden | 18 Mar 2012 19:12
Picon
Gravatar

Re: Node's __proto__

On Mar 16, 8:30 pm, Boris Zbarsky <bzbar... <at> mit.edu> wrote:
> On 3/16/12 3:15 PM, Eric J. Van der Velden wrote:
>
> > I understand for example that
> > Node.prototype.__proto__===Object.prototype, but although
> > uninteresting, I still would like to know what I should write on
> > the ... in Node.__proto__===....prototype.
>
> Per future specs, Node.__proto__ === Function.prototype, since Node is a
> Function object.
>
> In Gecko's current implementation, it depends.  In the new DOM bindings,
> the interface object's proto should be Function.prototype.  In the
> XPConnect bindings (which Node is at the moment, but hopefully not for
> much longer), I have no idea offhand.
>
> > Because Object is a function, Object.__proto__===Function.prototype.
> > So I thought: Function.__proto__===Function.prototype. I thought
> > Function in JavaScript similar to Object in Java. But it is not true.
>
> Function.__proto__ === Function.prototype, yes.
>
> Node is special, because it's actually a host object at the moment.
>
> > Also what do you mean by "each prototype has a flattened version of
> > all methods and properties it inherits"?
>
> That wasn't relevant to your question; it was about Node.prototype.
>
> -Boris
(Continue reading)

Boris Zbarsky | 19 Mar 2012 01:53
Picon
Favicon

Re: Node's __proto__

On 3/18/12 2:12 PM, Eric J. Van der Velden wrote:
> Function is defined in SpiderMonkey. Where is Node defined?

You mean in terms of our implementation, or in terms of the specs?

-Boris

Gmane