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

Class DirectiveBinder

packages/compiler/src/render3/view/t2_binder.ts:560–928  ·  view source on GitHub ↗

* Processes a template and matches directives on nodes (elements and templates). * * Usually used via the static `apply()` method.

Source from the content-addressed store, hash-verified

558 * Usually used via the static `apply()` method.
559 */
560class DirectiveBinder<DirectiveT extends DirectiveMeta> implements Visitor {
561 // Indicates whether we are visiting elements within a `defer` block
562 private isInDeferBlock = false;
563
564 private constructor(
565 private directiveMatcher: DirectiveMatcher<DirectiveT> | null,
566 private foreignMatcher: SelectorlessMatcher<ForeignComponentMeta> | null,
567 private directives: MatchedDirectives<DirectiveT>,
568 private foreignComponents: Map<Element, ForeignComponentMeta>,
569 private eagerDirectives: DirectiveT[],
570 private bindings: BindingsMap<DirectiveT>,
571 private references: ReferenceMap<DirectiveT>,
572 private conflictingHostDirectiveBindings: Map<
573 DirectiveOwner,
574 ConflictingHostDirectiveBinding<DirectiveT>[]
575 >,
576 ) {}
577
578 /**
579 * Process a template (list of `Node`s) and perform directive matching against each node.
580 *
581 * @param template the list of template `Node`s to match (recursively).
582 * @param selectorMatcher a `SelectorMatcher` containing the directives that are in scope for
583 * this template.
584 * @returns three maps which contain information about directives in the template: the
585 * `directives` map which lists directives matched on each node, the `bindings` map which
586 * indicates which directives claimed which bindings (inputs, outputs, etc), and the `references`
587 * map which resolves #references (`Reference`s) within the template to the named directive or
588 * template node.
589 */
590 static apply<DirectiveT extends DirectiveMeta>(
591 template: Node[],
592 directiveMatcher: DirectiveMatcher<DirectiveT> | null,
593 foreignMatcher: SelectorlessMatcher<ForeignComponentMeta> | null,
594 directives: MatchedDirectives<DirectiveT>,
595 foreignComponents: Map<Element, ForeignComponentMeta>,
596 eagerDirectives: DirectiveT[],
597 bindings: BindingsMap<DirectiveT>,
598 references: ReferenceMap<DirectiveT>,
599 conflictingHostDirectiveBindings: Map<
600 DirectiveOwner,
601 ConflictingHostDirectiveBinding<DirectiveT>[]
602 >,
603 ): void {
604 const matcher = new DirectiveBinder(
605 directiveMatcher,
606 foreignMatcher,
607 directives,
608 foreignComponents,
609 eagerDirectives,
610 bindings,
611 references,
612 conflictingHostDirectiveBindings,
613 );
614 matcher.ingest(template);
615 }
616
617 private ingest(template: Node[]): void {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected