selectByID method

  1. @override
Node selectByID(
  1. String id,
  2. Node? target,
  3. Node? self,
  4. DOMTreeMap? treeMap,
  5. DOMContext? context,
)
override

Implementation

@override
Node selectByID(String id, Node? target, Node? self, DOMTreeMap? treeMap,
    DOMContext? context) {
  if (self is Element) {
    var sel = _selectByID(self, id);
    if (sel != null) return sel;
  }

  if (target is Element) {
    var sel = _selectByID(target, id);
    if (sel != null) return sel;
  }

  if (treeMap != null) {
    var element = treeMap.rootElement;
    if (element is Element) {
      var sel = _selectByID(element, id);
      if (sel != null) return sel;
    }
  }

  var sel = document.querySelector('#$id');
  sel ??= _selectByID(document.documentElement!, id);

  return sel!;
}