isNodeInDOM method

bool isNodeInDOM(
  1. T? node
)

Implementation

bool isNodeInDOM(T? node) {
  var parents = getNodeParentsUntilRoot(node);
  if (parents.isEmpty) return false;

  var root = parents.last;

  if (isTextNode(root)) return false;

  var rootTag = getElementTag(root) ?? '';
  rootTag = rootTag.toLowerCase().trim();

  return rootTag == 'html' || rootTag == 'body' || rootTag == 'head';
}