MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / appendChild

Method appendChild

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

{@inheritDoc}

(final Node node)

Source from the content-addressed store, hash-verified

916 * {@inheritDoc}
917 */
918 @Override
919 public DomNode appendChild(final Node node) {
920 if (node == this) {
921 throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Can not add not to itself " + this);
922 }
923 final DomNode domNode = (DomNode) node;
924 if (domNode.isAncestorOf(this)) {
925 throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Can not add (grand)parent to itself " + this);
926 }
927
928 if (domNode instanceof DomDocumentFragment fragment) {
929 for (final DomNode child : fragment.getChildren()) {
930 appendChild(child);
931 }
932 }
933 else {
934 // clean up the new node, in case it is being moved
935 if (domNode.getParentNode() != null) {
936 domNode.detach();
937 }
938
939 basicAppend(domNode);
940
941 fireAddition(domNode);
942 }
943
944 return domNode;
945 }
946
947 /**
948 * Appends the specified node to the end of this node's children, assuming the specified

Callers 15

splitLastDomTextMethod · 0.95
appendChildMethod · 0.95
insertAdjacentElementMethod · 0.95
insertAdjacentTextMethod · 0.95
appendChildMethod · 0.95
afterMethod · 0.95
appendMethod · 0.95
prependMethod · 0.95
replaceChildrenMethod · 0.95
replaceWithMethod · 0.95
setInnerTextMethod · 0.95
setTextContentMethod · 0.95

Calls 6

isAncestorOfMethod · 0.95
getParentNodeMethod · 0.95
detachMethod · 0.95
basicAppendMethod · 0.95
fireAdditionMethod · 0.95
getChildrenMethod · 0.45

Tested by 2

splitLastDomTextMethod · 0.76
appendChildMethod · 0.76