Bug 12339 - XML DOM operations involving two documents don't match IE/Firefox behavior
Summary: XML DOM operations involving two documents don't match IE/Firefox behavior
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 420+
Hardware: Macintosh OS X 10.4
: P2 Normal
Assignee: Nobody
Depends on:
Blocks: 10489
  Show dependency treegraph
Reported: 2007-01-19 22:24 PST by Jesse Costello-Good
Modified: 2019-02-06 09:03 PST (History)
3 users (show)

See Also:

test case (449 bytes, text/html)
2009-02-16 02:47 PST, Alexey Proskuryakov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Costello-Good 2007-01-19 22:24:22 PST
I think that Safari probably has the more spec-compliant implementation but I report this for the sake of cross-browser AJAX compatibility.

appendChild, insertBefore, replaceChild, and setAttributeNode (could there be more?) fail when the argument is a node from a different XML document. In IE and Fx these methods behave as though the nodes are in the same document. No special logic is necessary to test whether the ownerDocument property of the two nodes is the same.

The work around is to use importNode(), call one of the above methods passing in the imported node, and remove the argument node from its parent node in the other document.
Comment 1 Maciej Stachowiak 2007-02-16 20:48:24 PST
Our behavior is more spec-compliant. We would consider changing it, but I think Firefox at least is considering changing to match the spec more closely instead
Comment 2 Alexey Proskuryakov 2009-02-16 02:47:02 PST
Created attachment 27689 [details]
test case

On this test case, WebKit and IE7 raise an exception, while Firefox 3.1b2 and Opera 9.63 do not. I'm not sure if that's the case reported here.
Comment 3 Alexey Proskuryakov 2009-02-16 02:47:51 PST
See also: bug 4569.
Comment 4 Johan "Spocke" Sörlin 2009-08-26 08:33:37 PDT
I don't think this is a bug. You should use importNode if you want to add a node from one document to another according to W3C specs.
Comment 5 Lucas Forschler 2019-02-06 09:03:21 PST
Mass moving XML DOM bugs to the "DOM" Component.