MCPcopy Index your code
hub / github.com/angular/angular / assertNoDuplicateDirectives

Function assertNoDuplicateDirectives

packages/core/src/render3/view/directives.ts:568–586  ·  view source on GitHub ↗
(directives: DirectiveDef<unknown>[])

Source from the content-addressed store, hash-verified

566}
567
568function assertNoDuplicateDirectives(directives: DirectiveDef<unknown>[]): void {
569 // The array needs at least two elements in order to have duplicates.
570 if (directives.length < 2) {
571 return;
572 }
573
574 const seenDirectives = new Set<DirectiveDef<unknown>>();
575
576 for (const current of directives) {
577 if (seenDirectives.has(current)) {
578 throw new RuntimeError(
579 RuntimeErrorCode.DUPLICATE_DIRECTIVE,
580 `Directive ${current.type.name} matches multiple times on the same element. ` +
581 `Directives can only match an element once.`,
582 );
583 }
584 seenDirectives.add(current);
585 }
586}

Callers 1

resolveDirectivesFunction · 0.85

Calls 2

hasMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…