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

Function findDirectiveDefMatches

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

Source from the content-addressed store, hash-verified

497 * If a component is matched (at most one), it is returned in first position in the array.
498 */
499export function findDirectiveDefMatches(
500 tView: TView,
501 tNode: TElementNode | TContainerNode | TElementContainerNode,
502): DirectiveDef<unknown>[] | null {
503 ngDevMode && assertFirstCreatePass(tView);
504 ngDevMode && assertTNodeType(tNode, TNodeType.AnyRNode | TNodeType.AnyContainer);
505
506 const registry = tView.directiveRegistry;
507 let matches: DirectiveDef<unknown>[] | null = null;
508 if (registry) {
509 for (let i = 0; i < registry.length; i++) {
510 const def = registry[i] as ComponentDef<any> | DirectiveDef<any>;
511 if (isNodeMatchingSelectorList(tNode, def.selectors!, /* isProjectionMode */ false)) {
512 matches ??= [];
513
514 if (isComponentDef(def)) {
515 if (ngDevMode) {
516 assertTNodeType(
517 tNode,
518 TNodeType.Element,
519 `"${tNode.value}" tags cannot be used as component hosts. ` +
520 `Please use a different tag to activate the ${stringify(def.type)} component.`,
521 );
522
523 if (matches.length && isComponentDef(matches[0])) {
524 throwMultipleComponentError(tNode, matches.find(isComponentDef)!.type, def.type);
525 }
526 }
527
528 matches.unshift(def);
529 } else {
530 matches.push(def);
531 }
532 }
533 }
534 }
535
536 return matches;
537}
538
539export function elementAttributeInternal(
540 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