Re: [DOMCore] ownerDocument of a Document object

On 6/3/11 2:44 PM, David Flanagan wrote:
> Also, the final step of the ensure algorithm is this:
>> If old's |ownerDocument
>> <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument>|
>> and new's |ownerDocument
>> <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument>|
>> are not the same, throw a |HIERARCHY_REQUEST_ERR
>> <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-hierarchy_request_err>|
> It seems to me that the previous steps of the algorithm ensure that they
> are the same and that this step is not necessary.

Unfortunately, no.  Invoking adoptNode can trigger arbitrary script 
execution before it returns in several different ways, which can change 
the ownerDocument of both 'new' and 'old'.  Changing the ownerDocument 
of 'old' while not messing with 'new', in particular, will make the 
ownerDocuments not match.

-Boris

Received on Monday, 6 June 2011 00:06:48 UTC