W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2012

Re: [dom] Need to describe the interaction of adoptNode with prototype chains

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Sun, 23 Dec 2012 22:08:10 -0800
Message-ID: <50D7F14A.2020800@mit.edu>
To: Cameron McCormack <cam@mcc.id.au>
CC: Anne van Kesteren <annevk@annevk.nl>, www-dom@w3.org, Bobby Holley <bholley@mozilla.com>
On 12/23/12 4:23 PM, Cameron McCormack wrote:
>    Unless otherwise specified, any newly created platform object that is
>    returned from an IDL attribute, operation, iterator or exception field
>    is associated with the same global environment that the corresponding
>    Function object that implements the attribute, operation, iterator
>    or exception field is associated with.

Maybe...  This makes sense as a specification device in which the JS 
reflection of objects is created at the same time as the underlying 
implementation, assuming there's a distinction between the two.  But in 
implementations in which the JS reflection might have a shorter lifetime 
and need to be recreated, having sane observable behavior means 
permanently associating each object with a global, which may well not 
match the Function object involved.  This is most obvious for nodes, but 
comes up for other objects too.  Say you have two windows win1 and win2 
and you run this script:

   win1.document.documentElement.__proto__ =
      win2.document.documentElement.__proto__
   var s = win1.document.documentElement.style;

s should probably be associated with win1, not win2 (and similar for 
less-insane things like using .call on the getter from win2 with an 
object from win1), since it's the .style of an element from win1...

The problem with having a default is that it means specification writers 
won't even think about how their stuff should be mapped to globals, 
which is good for the spec writers but bad for actual interop (again, 
assuming interop on this stuff matters).

> There isn't really anything in the spec at the moment that says that the
> global environment that a platform object is associated with (and thus
> what its [[Prototype]] is) cannot change, but it would be good to
> clarify that.

Agreed.

> Does it need to do anything other than change its [[Prototype]]?

Well, for nodes origin and effective script origin change, but that 
comes back to when and whether security checks are done or whether 
they're done at all, still an open question.

> I suppose per the ES spec you can't actually do that...

While true, it's not actually web-compatible in practice (pages depend 
on writable __proto__), so the ES spec will either change or not, but 
it's kinda fictional as things stand.

-Boris
Received on Monday, 24 December 2012 06:08:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 24 December 2012 06:08:50 GMT