attachFutureElement method

void attachFutureElement(
  1. DOMElement? domParent,
  2. T? parent,
  3. DOMNode domElement,
  4. T? templateElement,
  5. Object? futureElementResolved,
  6. DOMTreeMap<T> treeMap,
  7. DOMContext<T>? context,
)

Implementation

void attachFutureElement(
    DOMElement? domParent,
    T? parent,
    DOMNode domElement,
    T? templateElement,
    Object? futureElementResolved,
    DOMTreeMap<T> treeMap,
    DOMContext<T>? context) {
  if (futureElementResolved == null) {
    return;
  } else if (futureElementResolved is T) {
    treeMap.map(domElement, futureElementResolved as T, allowOverwrite: true);
    if (parent != null) {
      replaceChildElement(
          parent, templateElement, [futureElementResolved as T]);
    }
  } else if (parent != null) {
    var children = addExternalElementToElement(parent, futureElementResolved);

    if (isEmptyObject(children)) {
      removeChildFromElement(parent, templateElement);
    } else {
      var node = children!.first;
      treeMap.map(domElement, node);

      for (var child in children) {
        removeChildFromElement(parent, child);
      }
      replaceChildElement(parent, templateElement, children);
    }
  }
}