createComponentNodeAndAppend method

Expression createComponentNodeAndAppend(
  1. CompileDirectiveMetadata parentComponent,
  2. CompileDirectiveMetadata component,
  3. CompileElement parent,
  4. NodeReference elementRef,
  5. int nodeIndex,
  6. ElementAst ast,
)

Implementation

o.Expression createComponentNodeAndAppend(
  CompileDirectiveMetadata parentComponent,
  CompileDirectiveMetadata component,
  CompileElement parent,
  NodeReference elementRef,
  int nodeIndex,
  ElementAst ast,
) {
  final componentViewExpr = _createAppViewNodeAndComponent(
    parent,
    component,
    elementRef,
    nodeIndex,
    ast,
  );

  final root = componentViewExpr.prop(componentViewRootElementFieldName);
  if (isRootNodeOfHost(nodeIndex)) {
    // Assign the root element of the component view to a local variable. The
    // host view will use this as its root node, or the host element of a root
    // view container.
    _createMethod.addStmt(elementRef.toWriteStmt(root));
  } else {
    _initializeAndAppendNode(parent, elementRef, root);
  }
  _addDataDebugSource(
      elementRef,
      parentComponent.template?.templateUrl,
      (parentComponent.template?.templateOffset ?? 0) +
          ast.sourceSpan.start.offset);
  return componentViewExpr;
}