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

Class DirectiveBinder

packages/compiler/src/render3/view/t2_binder.ts:562–995  ·  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

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected