MCPcopy
hub / github.com/angular/angular / findDirectiveDefMatches

Function findDirectiveDefMatches

packages/core/src/render3/instructions/shared.ts:459–497  ·  view source on GitHub ↗
(
  tView: TView,
  tNode: TElementNode | TContainerNode | TElementContainerNode,
)

Source from the content-addressed store, hash-verified

457 * If a component is matched (at most one), it is returned in first position in the array.
458 */
459export function findDirectiveDefMatches(
460 tView: TView,
461 tNode: TElementNode | TContainerNode | TElementContainerNode,
462): DirectiveDef<unknown>[] | null {
463 ngDevMode && assertFirstCreatePass(tView);
464 ngDevMode && assertTNodeType(tNode, TNodeType.AnyRNode | TNodeType.AnyContainer);
465
466 const registry = tView.directiveRegistry;
467 let matches: DirectiveDef<unknown>[] | null = null;
468 if (registry) {
469 for (let i = 0; i < registry.length; i++) {
470 const def = registry[i] as ComponentDef<any> | DirectiveDef<any>;
471 if (isNodeMatchingSelectorList(tNode, def.selectors!, /* isProjectionMode */ false)) {
472 matches ??= [];
473
474 if (isComponentDef(def)) {
475 if (ngDevMode) {
476 assertTNodeType(
477 tNode,
478 TNodeType.Element,
479 `"${tNode.value}" tags cannot be used as component hosts. ` +
480 `Please use a different tag to activate the ${stringify(def.type)} component.`,
481 );
482
483 if (matches.length && isComponentDef(matches[0])) {
484 throwMultipleComponentError(tNode, matches.find(isComponentDef)!.type, def.type);
485 }
486 }
487
488 matches.unshift(def);
489 } else {
490 matches.push(def);
491 }
492 }
493 }
494 }
495
496 return matches;
497}
498
499export function elementAttributeInternal(
500 tNode: TNode,

Callers

nothing calls this directly

Calls 8

assertFirstCreatePassFunction · 0.90
assertTNodeTypeFunction · 0.90
isComponentDefFunction · 0.90
stringifyFunction · 0.90
findMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…