isInTree method

  1. @override
bool isInTree(
  1. Node? key
)
override

Returns true if key is in the tree.

Implementation

@override
bool isInTree(Node? key) {
  if (key == null) return false;
  var rootConn = root.isConnected;
  var keyConn = key.isConnected;
  // Optimization: If `rootConn` and `keyConn` differ,
  // `root` and `key` cannot be in the same DOM tree:
  if (rootConn != keyConn) {
    return false;
  } else {
    return root.contains(key);
  }
}