appendChild method

  1. @override
  2. @mustCallSuper
Node appendChild(
  1. Node child
)
override

Implementation

@override
@mustCallSuper
Node appendChild(Node child) {
  if (enableWebFProfileTracking) {
    WebFProfiler.instance.startTrackUICommandStep('Element.appendChild');
  }
  super.appendChild(child);
  // Update renderStyle tree.
  if (child is Element) {
    child.renderStyle.parent = renderStyle;
  }

  final box = renderBoxModel;
  if (isRendererAttachedToSegmentTree) {
    // Only append child renderer when which is not attached.
    if (!child.isRendererAttachedToSegmentTree && box != null && renderObjectManagerType == RenderObjectManagerType.WEBF_NODE) {
      RenderBox? after;
      if (box is RenderLayoutBox) {
        RenderLayoutBox? scrollingContentBox = box.renderScrollingContent;
        if (scrollingContentBox != null) {
          after = scrollingContentBox.lastChild;
        } else {
          after = box.lastChild;
        }
      } else if (box is ContainerRenderObjectMixin<RenderBox, ContainerParentDataMixin<RenderBox>>) {
        // TODO: improve implements
        after = (box as ContainerRenderObjectMixin<RenderBox, ContainerParentDataMixin<RenderBox>>).lastChild;
      }

      child.attachTo(this, after: after);
    }
  }

  if (enableWebFProfileTracking) {
    WebFProfiler.instance.finishTrackUICommandStep();
  }
  return child;
}