* Processes a template and matches directives on nodes (elements and templates). * * Usually used via the static `apply()` method.
| 511 | * Usually used via the static `apply()` method. |
| 512 | */ |
| 513 | class DirectiveBinder<DirectiveT extends DirectiveMeta> implements Visitor { |
| 514 | // Indicates whether we are visiting elements within a `defer` block |
| 515 | private isInDeferBlock = false; |
| 516 | |
| 517 | private constructor( |
| 518 | private directiveMatcher: DirectiveMatcher<DirectiveT> | null, |
| 519 | private directives: MatchedDirectives<DirectiveT>, |
| 520 | private eagerDirectives: DirectiveT[], |
| 521 | private missingDirectives: Set<string>, |
| 522 | private bindings: BindingsMap<DirectiveT>, |
| 523 | private references: ReferenceMap<DirectiveT>, |
| 524 | private conflictingHostDirectiveBindings: Map< |
| 525 | DirectiveOwner, |
| 526 | ConflictingHostDirectiveBinding<DirectiveT>[] |
| 527 | >, |
| 528 | ) {} |
| 529 | |
| 530 | /** |
| 531 | * Process a template (list of `Node`s) and perform directive matching against each node. |
| 532 | * |
| 533 | * @param template the list of template `Node`s to match (recursively). |
| 534 | * @param selectorMatcher a `SelectorMatcher` containing the directives that are in scope for |
| 535 | * this template. |
| 536 | * @returns three maps which contain information about directives in the template: the |
| 537 | * `directives` map which lists directives matched on each node, the `bindings` map which |
| 538 | * indicates which directives claimed which bindings (inputs, outputs, etc), and the `references` |
| 539 | * map which resolves #references (`Reference`s) within the template to the named directive or |
| 540 | * template node. |
| 541 | */ |
| 542 | static apply<DirectiveT extends DirectiveMeta>( |
| 543 | template: Node[], |
| 544 | directiveMatcher: DirectiveMatcher<DirectiveT> | null, |
| 545 | directives: MatchedDirectives<DirectiveT>, |
| 546 | eagerDirectives: DirectiveT[], |
| 547 | missingDirectives: Set<string>, |
| 548 | bindings: BindingsMap<DirectiveT>, |
| 549 | references: ReferenceMap<DirectiveT>, |
| 550 | conflictingHostDirectiveBindings: Map< |
| 551 | DirectiveOwner, |
| 552 | ConflictingHostDirectiveBinding<DirectiveT>[] |
| 553 | >, |
| 554 | ): void { |
| 555 | const matcher = new DirectiveBinder( |
| 556 | directiveMatcher, |
| 557 | directives, |
| 558 | eagerDirectives, |
| 559 | missingDirectives, |
| 560 | bindings, |
| 561 | references, |
| 562 | conflictingHostDirectiveBindings, |
| 563 | ); |
| 564 | matcher.ingest(template); |
| 565 | } |
| 566 | |
| 567 | private ingest(template: Node[]): void { |
| 568 | template.forEach((node) => node.visit(this)); |
| 569 | } |
| 570 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…