W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2013

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

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 16 Jan 2013 11:27:26 -0500
Message-ID: <50F6D4EE.1060208@mit.edu>
To: www-dom@w3.org
On 1/15/13 5:12 PM, Boris Zbarsky wrote:
>> If that's the goal, I think the best solution is to create a second
>> wrapper. Direct references to the old wrapper would continue to see
>> that wrapper's identity and custom properties (including those
>> implemented by its prototypes), but new references returned by the DOM
>> (e.g. via getElementById) would use a new wrapper, with a new identity
>> and a new set of custom properties defined by its new prototypes.
>
> I think changing object identity on adopt would unfortunately break web
> sites... but I'd welcome an existence proof that my fear is groundless!

One other comment here.  What Gecko _actually_ does on adopt is:

1)  Create a new wrapper with the new proto chain and whatnot.
2)  Copy all own property from the old wrapper to the new wrapper.
3)  Change the old wrapper's internals to make it into a proxy for the
     new wrapper without changing object identity.

Since we create membrane-like proxies on all cross-global access, and 
automatically unwrap them as needed when re-crossing the boundary, this 
does not have object identity issues, since you can't ever compare two 
objects from two different globals to each other.

But that's an implementation detail, really; the observable effect is 
that it looks like the prototype changed.

-Boris
Received on Wednesday, 16 January 2013 16:27:56 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 16 January 2013 16:28:01 GMT