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

Method checkChildHierarchy

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

Check for insertion errors for a new child node. This is overridden by derived classes to enforce which types of children are allowed. @param newChild the new child node that is being inserted below this node @throws DOMException HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does

(final Node newChild)

Source from the content-addressed store, hash-verified

1275 * one that created this node.
1276 */
1277 protected void checkChildHierarchy(final Node newChild) throws DOMException {
1278 Node parentNode = this;
1279 while (parentNode != null) {
1280 if (parentNode == newChild) {
1281 throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "Child node is already a parent.");
1282 }
1283 parentNode = parentNode.getParentNode();
1284 }
1285 final Document thisDocument = getOwnerDocument();
1286 final Document childDocument = newChild.getOwnerDocument();
1287 if (childDocument != thisDocument && childDocument != null) {
1288 throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, "Child node " + newChild.getNodeName()
1289 + " is not in the same Document as this " + getNodeName() + ".");
1290 }
1291 }
1292
1293 /**
1294 * Lifecycle method invoked whenever a node is added to a page. Intended to

Callers

nothing calls this directly

Calls 3

getParentNodeMethod · 0.95
getOwnerDocumentMethod · 0.95
getNodeNameMethod · 0.45

Tested by

no test coverage detected