generateDOMAsyncElement method

T? generateDOMAsyncElement(
  1. DOMElement? domParent,
  2. T? parent,
  3. DOMAsync domAsync,
  4. DOMTreeMap<T> treeMap,
  5. DOMContext<T>? context,
)

Implementation

T? generateDOMAsyncElement(DOMElement? domParent, T? parent,
    DOMAsync domAsync, DOMTreeMap<T> treeMap, DOMContext<T>? context) {
  T? templateElement;
  if (domAsync.loading != null) {
    var nodes = DOMNode.parseNodes(domAsync.loading);

    if (nodes.isNotEmpty) {
      DOMNode rootNode;
      if (nodes.length == 1) {
        rootNode = nodes.first;
      } else {
        rootNode = $div(content: nodes);
      }

      templateElement = build(domParent, parent, rootNode, treeMap, context);
    }
  }

  templateElement ??= createElement('template');

  var future = domAsync.resolveFuture!;

  return _generateFutureElementImpl(
      domParent, parent, domAsync, templateElement, future, treeMap, context);
}