projectNodesIntoElement method

void projectNodesIntoElement(
  1. CompileElement target,
  2. int sourceAstIndex,
  3. int? ngContentIndex
)

Implementation

void projectNodesIntoElement(
    CompileElement target, int sourceAstIndex, int? ngContentIndex) {
  // The projected nodes originate from a different view, so we don't
  // have debug information for them.
  var parentRenderNode = _getParentRenderNode(target);
  // AppView.projectableNodes property contains the list of nodes
  // to project for each NgContent.
  // Creates a call to project(parentNode, nodeIndex).
  var nodesExpression = ViewProperties.projectedNodes.key(
      o.literal(sourceAstIndex),
      o.ArrayType(o.importType(Identifiers.HTML_NODE)));
  var isRootNode = !identical(target.view, this);
  if (!identical(parentRenderNode, o.NULL_EXPR)) {
    _createMethod.addStmt(o.InvokeMemberMethodExpr(
        'project', [parentRenderNode, o.literal(sourceAstIndex)]).toStmt());
  } else if (isRootNode) {
    if (!identical(viewType, ViewType.component)) {
      // store root nodes only for embedded/host views
      rootNodesOrViewContainers.add(nodesExpression);
    }
  } else {
    if (target.component != null && ngContentIndex != null) {
      target.addContentNode(ngContentIndex, nodesExpression);
    }
  }
}