visitElementBefore method

  1. @override
bool visitElementBefore(
  1. Element element
)
override

Called when an Element has been reached, before its children have been visited.

Returns false to skip its children.

Implementation

@override
bool visitElementBefore(Element element) {
  // Hackish. Separate block-level elements with newlines.
  if (buffer.isNotEmpty && _shallBreakBefore(element.tag)) {
    buffer.writeln();
  }

  _writeOpenTagStart(element);
  _lastVisitedTag = element.tag;

  if (element.isEmpty) {
    // Empty element like <hr/>.
    _writeOpenTagEnd(element);
    return false;
  } else {
    _elementStack.add(element);
    _writeOpenTagEnd(element);
    return true;
  }
}