replaceBy method

bool replaceBy(
  1. List? elements, {
  2. bool remap = false,
})

Replaces this node with elements.

  • remap If true will remap the new element at treeMap (only if elements represents 1 element).

Implementation

bool replaceBy(List? elements, {bool remap = false}) {
  if (elements == null) return false;
  var e = domGenerator.toElements(elements);
  var ok = domGenerator.replaceElement(node, e);

  var treeMap = this.treeMap;

  if (ok && treeMap != null && domNode != null) {
    treeMap.removeByDOMNode(domNode);

    if (remap && e != null && e.length == 1) {
      var node2 = e.first;
      var domNode2 = domGenerator.revert(treeMap, node2);
      if (domNode2 != null) {
        treeMap.mapTree(domNode2, node2);
      }
    }
  }

  return ok;
}