Created
November 18, 2011 23:44
-
-
Save Raynos/1378123 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var adoptNode = (function () { | |
function setOwnerDocument(node, doc) { | |
// implement this. Step 1 of DOM4 adopt a node algorithm | |
node.triggerBaseUrlChange(); | |
node._ownerDocument = doc; | |
node._attributes._ownerDocument = doc; | |
[].forEach.call(node.childNodes, function (node) { | |
setOwnerDocument(node, doc); | |
}); | |
} | |
function adoptNode(node, doc) { | |
if (node.nodeType === Node.DOCUMENT_NODE) { | |
throw new core.DOMException(NOT_SUPPORTED_ERR, "Attempted to adopt a Document node into another node"); | |
} | |
node.parentNode = null; | |
setOwnerDocument(node, doc); | |
} | |
return adoptNode; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment