attach method

  1. @override
void attach(
  1. covariant DomRenderObject child, {
  2. covariant DomRenderObject? after,
})
override

Implementation

@override
void attach(DomRenderObject child, {DomRenderObject? after}) {
  try {
    child.parent = this;

    final parentNode = node;
    final childNode = child.node;

    assert(parentNode.instanceOfString('Element'));
    if (childNode == null) return;

    final afterNode = after?.node;

    if (childNode.previousSibling == afterNode && childNode.parentNode == parentNode) {
      return;
    }

    if (kVerboseMode) {
      print("Attach node $childNode of $parentNode after $afterNode");
    }

    if (afterNode == null) {
      parentNode!.insertBefore(childNode, parentNode.childNodes.item(0));
    } else {
      parentNode!.insertBefore(childNode, afterNode.nextSibling);
    }
  } finally {
    child.finalize();
  }
}