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: Bobby Holley <bholley@mozilla.com>
Date: Sun, 23 Dec 2012 16:14:02 -0800
Message-ID: <CAKBxTcKT1FF_0wx5p+ffCExRttonZ_Bh481X_OZWpDHQ7Brx3w@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: Anne van Kesteren <annevk@annevk.nl>, www-dom@w3.org, Cameron McCormack <cam@mcc.id.au>
On Sun, Dec 23, 2012 at 4:07 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> On 12/23/12 1:09 AM, Anne van Kesteren wrote:
>
>> What happens with document.open()? Does that replace the proto as well?
>>
>
> In Gecko?
>
> I think it might do something weird like replacing the proto chain for
> descendants of the document but not all of the nodes that have it as
> ownerDocument or something.  Bobby might know.
>

On document.open, we do the following, in order:

1) Eject all the content from the document.
2) Reparent the document into the new scope.
3) Reparent everything in the old scope whose parent chain eventually led
to the document ("orphan fixup").

For DOM object (and anything with classinfo), the reparenting algorithm
finds the equivalent prototype in the new scope:
https://mxr.mozilla.org/mozilla-central/source/js/xpconnect/src/XPCWrappedNative.cpp#1491

Cheers,
bholley
Received on Tuesday, 25 December 2012 19:33:58 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 25 December 2012 19:34:01 GMT