Document.importNode VS Node.cloneNode (real example)

Alohci is right: there’s not much of a difference, since web compatibility forced the browsers to implicitly adoptNode() before inserting a node into another document.

Before you insert the cloned node into a new document, there’s a difference: the owner document of the node returned by the cloneNode(original) is the same as of the original node, and the new document if you call newDocument.importNode(original). You can see this difference if you use ownerDocument or related properties (such as baseURI).

But if you call importNode on the same document that the original node belongs to, there’s no difference whatsoever.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)