merge method
Merges this node with other
. Useful for consecutive text elements like
b
, i
and span
.
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 DOMElement) {
if (tag != other.tag) return false;
other.remove();
absorbNode(other);
return true;
} else if (other is TextNode) {
other.remove();
absorbNode(other);
return true;
} else {
return false;
}
}