Document.importNode in specification
Node.cloneNode in specification
This two methods work equally. Please give me real example in which I can see the difference between this methods.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With