{@inheritDoc}
(final Node node)
| 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 |