diff --git a/packages/compiler-cli/src/ngtsc/typecheck/testing/index.ts b/packages/compiler-cli/src/ngtsc/typecheck/testing/index.ts index cd1546a354b..4186a042b54 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/testing/index.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/testing/index.ts @@ -826,7 +826,7 @@ function prepareDeclarations( for (const meta of directives) { registry.set(meta.name, [meta, ...hostDirectiveResolder.resolve(meta)]); } - return {matcher: new SelectorlessMatcher(registry), pipes}; + return {matcher: new SelectorlessMatcher(registry), pipes}; } else { const matcher = new SelectorMatcher(); for (const meta of directives) { diff --git a/packages/compiler/src/directive_matching.ts b/packages/compiler/src/directive_matching.ts index 52214e7117d..2a768e9f849 100644 --- a/packages/compiler/src/directive_matching.ts +++ b/packages/compiler/src/directive_matching.ts @@ -474,9 +474,9 @@ export class SelectorContext { } export class SelectorlessMatcher { - constructor(private registry: Map) {} + constructor(private registry: Map) {} - match(name: string): T | null { - return this.registry.get(name) ?? null; + match(name: string): T[] { + return this.registry.has(name) ? this.registry.get(name)! : []; } } diff --git a/packages/compiler/src/render3/view/t2_api.ts b/packages/compiler/src/render3/view/t2_api.ts index 0d65d9e6673..8f055851bbe 100644 --- a/packages/compiler/src/render3/view/t2_api.ts +++ b/packages/compiler/src/render3/view/t2_api.ts @@ -272,5 +272,18 @@ export interface BoundTarget { /** * Whether a given node is located in a `@defer` block. */ - isDeferred(node: Element | Component): boolean; + isDeferred(node: Element): boolean; + + /** + * Returns the directives that are owned by a specific component/directive node. This is either + * the directive being referenced itself or its host directives. + * @param node Node for which to retrieve the owned directives. + */ + getOwnedDirectives(node: Component | Directive): DirectiveT[] | null; + + /** + * Checks whether a component/directive that was referenced directly in the template exists. + * @param name Name of the component/directive. + */ + referencedDirectiveExists(name: string): boolean; } diff --git a/packages/compiler/src/render3/view/t2_binder.ts b/packages/compiler/src/render3/view/t2_binder.ts index ef49e9b0181..41d9125ac24 100644 --- a/packages/compiler/src/render3/view/t2_binder.ts +++ b/packages/compiler/src/render3/view/t2_binder.ts @@ -93,7 +93,10 @@ type ReferenceMap = Map< >; /** Mapping between AST nodes and the directives that have been matched on them. */ -type MatchedDirectives = Map