CompileElement constructor
CompileElement(
- CompileElement? parent,
- CompileView? view,
- int? nodeIndex,
- NodeReference renderNode,
- TemplateAst? sourceAst,
- CompileDirectiveMetadata? component,
- List<
CompileDirectiveMetadata> _directives, - List<
ProviderAst> _resolvedProvidersArray, - bool hasViewContainer,
- bool hasEmbeddedView,
- List<
ReferenceAst> references, { - Expression? componentView,
- bool hasTemplateRefQuery = false,
- bool isHtmlElement = false,
Implementation
CompileElement(
super.parent,
super.view,
super.nodeIndex,
super.renderNode,
this.sourceAst,
this.component,
this._directives,
this._resolvedProvidersArray,
this.hasViewContainer,
this.hasEmbeddedView,
List<ReferenceAst> references, {
this.componentView,
this.hasTemplateRefQuery = false,
this.isHtmlElement = false,
}) {
_providers = ProviderResolver(this, parent?._providers);
if (references.isNotEmpty) {
for (final reference in references) {
final token = reference.value;
referenceTokens[reference.name] = token;
_publishesTemplateRef =
_publishesTemplateRef ||
token != null && token.equalsTo(Identifiers.templateRefToken);
}
}
htmlElement = renderNode.toReadExpr();
_providers.add(Identifiers.elementToken, htmlElement);
_providers.add(Identifiers.elementDomToken, htmlElement);
_providers.add(Identifiers.htmlElementToken, htmlElement);
_providers.add(Identifiers.htmlElementDomToken, htmlElement);
var readInjectorExpr = o.InvokeMemberMethodExpr('injector', [
o.literal(nodeIndex),
]);
_providers.add(Identifiers.injectorToken, readInjectorExpr);
if (hasViewContainer || hasEmbeddedView) {
appViewContainer = view!.createViewContainer(
renderNode,
nodeIndex!,
!hasViewContainer,
isRootElement ? null : parent!.nodeIndex,
);
_providers.add(Identifiers.viewContainerToken, appViewContainer!);
}
// This logic was copied from the setter for `componentView`, which was
// removed when `componentView` was made final (as there was no need for it
// to ever be reassigned).
if (componentView != null) {
final indexCount = component!.template!.ngContentSelectors.length;
for (var i = 0; i < indexCount; i++) {
contentNodesByNgContentIndex.add([]);
}
}
}