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

Class DirectiveBinder

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

525 * Usually used via the static `apply()` method.
526 */
527class DirectiveBinder<DirectiveT extends DirectiveMeta> implements Visitor {
528 // Indicates whether we are visiting elements within a `defer` block
529 private isInDeferBlock = false;
530
531 private constructor(
532 private directiveMatcher: DirectiveMatcher<DirectiveT> | null,
533 private foreignMatcher: SelectorlessMatcher<ForeignComponentMeta> | null,
534 private directives: MatchedDirectives<DirectiveT>,
535 private foreignComponents: Map<Element, ForeignComponentMeta>,
536 private eagerDirectives: DirectiveT[],
537 private missingDirectives: Set<string>,
538 private bindings: BindingsMap<DirectiveT>,
539 private references: ReferenceMap<DirectiveT>,
540 private conflictingHostDirectiveBindings: Map<
541 DirectiveOwner,
542 ConflictingHostDirectiveBinding<DirectiveT>[]
543 >,
544 ) {}
545
546 /**
547 * Process a template (list of `Node`s) and perform directive matching against each node.
548 *
549 * @param template the list of template `Node`s to match (recursively).
550 * @param selectorMatcher a `SelectorMatcher` containing the directives that are in scope for
551 * this template.
552 * @returns three maps which contain information about directives in the template: the
553 * `directives` map which lists directives matched on each node, the `bindings` map which
554 * indicates which directives claimed which bindings (inputs, outputs, etc), and the `references`
555 * map which resolves #references (`Reference`s) within the template to the named directive or
556 * template node.
557 */
558 static apply<DirectiveT extends DirectiveMeta>(
559 template: Node[],
560 directiveMatcher: DirectiveMatcher<DirectiveT> | null,
561 foreignMatcher: SelectorlessMatcher<ForeignComponentMeta> | null,
562 directives: MatchedDirectives<DirectiveT>,
563 foreignComponents: Map<Element, ForeignComponentMeta>,
564 eagerDirectives: DirectiveT[],
565 missingDirectives: Set<string>,
566 bindings: BindingsMap<DirectiveT>,
567 references: ReferenceMap<DirectiveT>,
568 conflictingHostDirectiveBindings: Map<
569 DirectiveOwner,
570 ConflictingHostDirectiveBinding<DirectiveT>[]
571 >,
572 ): void {
573 const matcher = new DirectiveBinder(
574 directiveMatcher,
575 foreignMatcher,
576 directives,
577 foreignComponents,
578 eagerDirectives,
579 missingDirectives,
580 bindings,
581 references,
582 conflictingHostDirectiveBindings,
583 );
584 matcher.ingest(template);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected