MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / cloneNode

Method cloneNode

src/main/java/org/htmlunit/html/DomNode.java:851–876  ·  view source on GitHub ↗

{@inheritDoc}

(final boolean deep)

Source from the content-addressed store, hash-verified

849 * {@inheritDoc}
850 */
851 @Override
852 public DomNode cloneNode(final boolean deep) {
853 final DomNode newnode;
854 try {
855 newnode = (DomNode) clone();
856 }
857 catch (final CloneNotSupportedException e) {
858 throw new IllegalStateException("Clone not supported for node [" + this + "]", e);
859 }
860
861 newnode.parent_ = null;
862 newnode.nextSibling_ = null;
863 newnode.previousSibling_ = null;
864 newnode.scriptObject_ = null;
865 newnode.firstChild_ = null;
866 newnode.attachedToPage_ = false;
867
868 // if deep, clone the children too.
869 if (deep) {
870 for (DomNode child = firstChild_; child != null; child = child.nextSibling_) {
871 newnode.appendChild(child.cloneNode(true));
872 }
873 }
874
875 return newnode;
876 }
877
878 /**
879 * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>

Callers 5

cloneNodeMethod · 0.95
importNodeMethod · 0.95
cloneNodeMethod · 0.95
cloneContentsMethod · 0.95
insertNodeMethod · 0.45

Calls 2

appendChildMethod · 0.95
cloneMethod · 0.45

Tested by

no test coverage detected