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

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 UTC