Checks to see if a parent element contains a child elemnt (including inside
shadow DOM).
@param {Node} parent The parent element.
@param {Node} child The child element.
@return {boolean} True if the parent node contains the child node.
559788
function containsDeep(parent, child) {
        var node = child;
        while (node) {
            if (node == parent) return true;

            node = getParentNode(node);
        }
        return false;
    }
1180493
function(parent) {
    if (!parent) return this;
    if (typeof parent.append === 'function') {
      parent.append(this);
    } else if (typeof parent.appendChild === 'function') {
      parent.appendChild(this._element);
      this.onAppend();
    }
    return this;
  }
1085782
boolean hasChildElement() {
        org.w3c.dom.NodeList nodes = this.dom.getChildNodes();
        for (int i=0; i<nodes.getLength(); i++) {
            if (nodes.item(i).getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) return true;
        }
        return false;
    }
397090
function checkChildren( children, newParentName ) {
		var allowed = DTD[ newParentName ];

		for ( var i = 0, l = children.length, child; i < l; ++i ) {
			child = children[ i ];
			if ( child.type == CKEDITOR.NODE_ELEMENT && !allowed[ child.name ] )
				return false;
		}

		return true;
	}
1227752
public boolean canContain(int parent, int child) {
    if (nofeatureElements.get(parent)) {
      // It's hard to interrogate a browser about the behavior of
      // <noscript> in scriptless mode using JavaScript, and the
      // behavior of <noscript> is more dangerous when in that mode,
      // so we hardcode that mode here as a worst case assumption.
      return true;
    }

    return child == TEXT_NODE
        ? canContainText(parent)
        : canContain.get(parent, child);
  }
20769
def contains?(child)
      children.any? { |c|
        (c.kind_of?(Layout) && c.contains?(child)) || c == child
      }
    end
202832
public final boolean hasChild(Node child) {
    for (Node n = first; n != null; n = n.next) {
      if (child == n) {
        return true;
      }
    }
    return false;
  }
875705
function isParentNodeType(parent, nodeType) {
            return parent.type === nodeType ||
                (parent.body && parent.body.type === nodeType) ||
                (parent.consequent && parent.consequent.type === nodeType);
        }
611236
function findChildContainingNode(root, node) {
  const parentNode = node.parentNode;
  return parentNode === root ?
    node :
    findChildContainingNode(root, parentNode);
}
182108
public boolean canAcceptParent(ElementBase parent) {
        if (!canAcceptParent()) {
            return false;
        }
        
        if (!canAcceptParent(getClass(), parent.getClass())) {
            rejectReason = getDisplayName() + " does not accept " + parent.getDisplayName() + " as a parent.";
        } else {
            rejectReason = null;
        }
        
        return rejectReason == null;
    }
1289816
function shouldIndentChildNode(parent, child) {
                return nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, /*indentByDefault*/ false);
            }
1238960
function(doc, nodes, selector) {
        var parent = module.exports.resolveParent(doc, selector);
        if (!parent) return false;

        nodes.forEach(function (node) {
            var matchingKid = null;
            if ((matchingKid = findChild(node, parent)) !== null) {
                // stupid elementtree takes an index argument it doesn't use
                // and does not conform to the python lib
                parent.remove(matchingKid);
            }
        });

        return true;
    }
702618
function( ancestor, descendant, within )
    {
        var node = within ? descendant.parentNode : descendant;
        while( node )
        {
            if( node === ancestor )
                return true;
            node = node.parentNode;
        }
        return false;
    }
130536
public static void ensureChildElement(DomXmlElement parentElement, DomXmlElement childElement) {
    Node parent = childElement.unwrap().getParentNode();
    if (parent == null || !parentElement.unwrap().isEqualNode(parent)) {
      throw LOG.elementIsNotChildOfThisElement(childElement, parentElement);
    }
  }
98535
static boolean isElementParentName(Element element, String name) {
        Element parent = element.getParentElement();
        if (parent == null) {
            return false;
        }
        return isElementName(parent, name);
    }
829794
function childOf(p, c) {
  if (p === c) return false;
  while (c && c !== p) c = c.parentNode;
  return c === p;
}
881888
function(node, child) {
      var hasContains = (window.Node && window.Node.prototype && Node.prototype.contains);
      var findFn = hasContains ? angular.bind(node, node.contains) : angular.bind(node, function(arg) {
        // compares the positions of two nodes and returns a bitmask
        return (node === child) || !!(this.compareDocumentPosition(arg) & 16);
      });

      return findFn(child);
    }