previousText property

String previousText

Implementation

String get previousText {
  if (parentNode == null) {
    return '';
  }
  if (parentNode!.firstChild == this) {
    return parentNode!.previousText;
  }
  var prevText = '';
  for (final child in parentNode!.nodes) {
    if (this == child) {
      break;
    }
    if (child is dom.Element && child.localName?.toLowerCase() == 'br') {
      prevText = '\n';
    } else if (child is dom.Element) {
      prevText = child.lastChildText;
    } else if (child is dom.Text) {
      prevText = child.text;
    }
  }
  return prevText;
}