Bug 31029
Summary: | Cannot add AJAX loaded content in hierarchy without clone it. | ||
---|---|---|---|
Product: | WebKit | Reporter: | chameleon <gessos.paul> |
Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | Normal | CC: | ap, cdumez |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | All | ||
OS: | All | ||
URL: | http://www.agiasofia.gr/test/ |
chameleon
I load XHTML with following code:
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", '?a=3', false);
xmlHttp.send(null);
Then replace a node in document with loaded content:
var where = document.getElementById('here_for_webkit_only');
where.parentNode.replaceChild(xmlHttp.responseXML.documentElement, where);
FAIL!!!!
I must use:
var where = document.getElementById('here_for_webkit_only');
where.parentNode.replaceChild(xmlHttp.responseXML.documentElement.cloneNode(true), where);
SUCCESS!!!!
Is there a special reason for this?
Check it online at given URL. (the third bug in a row)
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Alexey Proskuryakov
Yes, our behavior is in accordance with DOM 3 Core specification, please see <http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-785887307>: "WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node."
I would actually suggest that you use importNode, not cloneNode, as that avoids the need to make copies, and is faster.
Resolving as INVALID, because our behavior appears correct per the spec, and we are not aware of actual sites broken by this (which would make us consider diverging from the spec).
chameleon
You are right.
Sorry for false alert.
Lucas Forschler
Mass moving XML DOM bugs to the "DOM" Component.