Node's __proto__

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Node's __proto__

Eric J. Van der Velden
Hello,

What is Node.__proto__ , or Element.__proto__ ?

Thanks

Eric J.
_______________________________________________
dev-tech-dom mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-dom
Reply | Threaded
Open this post in threaded view
|

Re: Node's __proto__

Bobby Holley-2
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 <
[hidden email]> wrote:

> Hello,
>
> What is Node.__proto__ , or Element.__proto__ ?
>
> Thanks
>
> Eric J.
> _______________________________________________
> dev-tech-dom mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-dom
>
_______________________________________________
dev-tech-dom mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-dom
Reply | Threaded
Open this post in threaded view
|

Re: Node's __proto__

Eric J. Van der Velden
In reply to this post by Eric J. Van der Velden
On Mar 12, 7:00 am, Bobby Holley <[hidden email]> 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 <
>
>
>
>
>
>
>
> [hidden email]> wrote:
> > Hello,
>
> > What is Node.__proto__ , or Element.__proto__ ?
>
> > Thanks
>
> > Eric J.
> > _______________________________________________
> > dev-tech-dom mailing list
> > [hidden email]
> >https://lists.mozilla.org/listinfo/dev-tech-dom

Hi Bobby,

Thank you very much for taking the effort to explain this to me.

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. I'll tell you why. I
thought I had it all figured out, but it apparently is not true.
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.
So what is Function.__proto__, Node.__proto__, ...?

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

Thanks,

Eric J.
_______________________________________________
dev-tech-dom mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-dom
Reply | Threaded
Open this post in threaded view
|

Re: Node's __proto__

Boris Zbarsky
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
_______________________________________________
dev-tech-dom mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-dom
Reply | Threaded
Open this post in threaded view
|

Re: Node's __proto__

Eric J. Van der Velden
On Mar 16, 8:30 pm, Boris Zbarsky <[hidden email]> 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

Hi Boris,

Thank you very much.

Function is defined in SpiderMonkey. Where is Node defined?

Thanks,

Eric J.
_______________________________________________
dev-tech-dom mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-dom
Reply | Threaded
Open this post in threaded view
|

Re: Node's __proto__

Boris Zbarsky
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
_______________________________________________
dev-tech-dom mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-dom