getElementById method

Element? getElementById(
  1. String id
)

Implementation

Element? getElementById(String id) {
  if (_body.id == id) return _body;
  final inHead = headChildren
      .expand((el) => [el, ...el.descendants])
      .where((el) => el.id == id)
      .firstOrNull;
  if (inHead != null) return inHead;
  return _body.descendants.where((el) => el.id == id).firstOrNull;
}