I have a cloned node that I want to delete a child node from, but I want to do this before I append the cloned node to the document. When I try this I get an error ‘Node was not found’.
This is the output from testing in firebug’s console. You can see that the node I want to delete (deleteBox.previousSibling) does exist. newCountry is the cloned node that has not yet been appended to the document.
>>> deleteBox.previousSibling
<a class="chkboxChkd" href="#">
>>> newCountry
<div id="countryContainer-xxxx2" class="countryContainer">
>>> newCountry.removeChild(deleteBox.previousSibling);
[Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NotFoundError)" location: "<unknown>"] { constructor=DOMException, code=8, INDEX_SIZE_ERR=1, more...}
>>> document.createDocumentFragment().appendChild(newCountry).removeChild(deleteBox.previousSibling);
[Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NotFoundError)" location: "<unknown>"] { constructor=DOMException, code=8, INDEX_SIZE_ERR=1, more...}
How can I delete a node from a fragment that has not been appended to the document yet?