merge method

  1. @override
bool merge(
  1. DOMNode other, {
  2. bool onlyConsecutive = true,
})
override

Merges other node into this node.

Implementation

@override
bool merge(DOMNode other, {bool onlyConsecutive = true}) {
  if (onlyConsecutive) {
    if (isPreviousNode(other)) {
      return other.merge(this, onlyConsecutive: false);
    } else if (!isNextNode(other)) {
      return false;
    }
  }

  if (other is TextNode) {
    other.remove();
    absorbNode(other);
    return true;
  } else if (other is TemplateNode) {
    other.remove();
    absorbNode(other);
    return true;
  } else if (other is DOMElement &&
      other.isStringElement &&
      (other.isEmptyContent || other.hasOnlyTextNodes)) {
    other.remove();
    absorbNode(other);
    return true;
  } else {
    return false;
  }
}