child
element is a descendant of the parent
element.const isDescendant = parent.contains(child);
// Check if `child` is a descendant of `parent`const isDescendant = function (parent, child) {let node = child.parentNode;while (node) {if (node === parent) {return true;}// Traverse up to the parentnode = node.parentNode;}// Go up until the root but couldn't find the `parent`return false;};