MCPcopy Create free account
hub / github.com/angular/angular / createRootTView

Function createRootTView

packages/core/src/render3/component_ref.ts:456–544  ·  view source on GitHub ↗
(
  rootSelectorOrNode: any,
  componentDef: ComponentDef<unknown>,
  componentBindings: Binding[] | undefined,
  directives: (Type<unknown> | DirectiveWithBindings<unknown>)[] | undefined,
  allowNonStandaloneDirectives?: boolean,
)

Source from the content-addressed store, hash-verified

454}
455
456function createRootTView(
457 rootSelectorOrNode: any,
458 componentDef: ComponentDef<unknown>,
459 componentBindings: Binding[] | undefined,
460 directives: (Type<unknown> | DirectiveWithBindings<unknown>)[] | undefined,
461 allowNonStandaloneDirectives?: boolean,
462): TView {
463 const tAttributes = rootSelectorOrNode
464 ? ['ng-version', '0.0.0-PLACEHOLDER']
465 : // Extract attributes and classes from the first selector only to match VE behavior.
466 extractAttrsAndClassesFromSelector(componentDef.selectors[0]);
467 let creationBindings: Binding[] | null = null;
468 let updateBindings: Binding[] | null = null;
469 let varsToAllocate = 0;
470
471 if (componentBindings) {
472 for (const binding of componentBindings as BindingInternal[]) {
473 varsToAllocate += binding[BINDING].requiredVars;
474
475 if (binding.create) {
476 binding.targetIdx = 0;
477 (creationBindings ??= []).push(binding);
478 }
479
480 if (binding.update) {
481 binding.targetIdx = 0;
482 (updateBindings ??= []).push(binding);
483 }
484 }
485 }
486
487 if (directives) {
488 for (let i = 0; i < directives.length; i++) {
489 const directive = directives[i];
490 if (typeof directive !== 'function') {
491 for (const binding of directive.bindings as BindingInternal[]) {
492 varsToAllocate += binding[BINDING].requiredVars;
493 const targetDirectiveIdx = i + 1;
494
495 if (binding.create) {
496 binding.targetIdx = targetDirectiveIdx;
497 (creationBindings ??= []).push(binding);
498 }
499
500 if (binding.update) {
501 binding.targetIdx = targetDirectiveIdx;
502 (updateBindings ??= []).push(binding);
503 }
504 }
505 }
506 }
507 }
508
509 const directivesToApply: DirectiveDef<unknown>[] = [componentDef];
510 if (directives) {
511 for (const directive of directives) {
512 const directiveType = typeof directive === 'function' ? directive : directive.type;
513 const directiveDef = ngDevMode

Callers 1

createComponentRefMethod · 0.85

Calls 7

getDirectiveDefOrThrowFunction · 0.90
getDirectiveDefFunction · 0.90
stringifyForErrorFunction · 0.90
createTViewFunction · 0.90
getRootTViewTemplateFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected