replaceChildElement method

  1. @override
bool replaceChildElement(
  1. Node parent,
  2. Node? child1,
  3. List<Node>? child2
)
override

Implementation

@override
bool replaceChildElement(Node parent, Node? child1, List<Node>? child2) {
  if (parent is Element) {
    var idx = parent.nodes.indexOf(child1!);
    if (idx >= 0) {
      parent.nodes.removeAt(idx);
      for (var i = 0; i < child2!.length; ++i) {
        var e = child2[i];
        parent.nodes.insert(idx + i, e);
      }
      return true;
    }
  }
  return false;
}