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

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 UTC