Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): enable the new directive composition API #47642

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions goldens/public-api/core/index.md
Expand Up @@ -439,6 +439,11 @@ export interface Directive {
host?: {
[key: string]: string;
};
hostDirectives?: (Type<unknown> | {
directive: Type<unknown>;
inputs?: string[];
outputs?: string[];
})[];
inputs?: string[];
jit?: true;
outputs?: string[];
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/metadata/directives.ts
Expand Up @@ -332,6 +332,17 @@ export interface Directive {
* @developerPreview
*/
standalone?: boolean;

/**
* Standalone directives that should be applied to the host whenever the directive is matched.
* By default none of the inputs or outputs of the host directives will be available on the host,
* unless they are specified in the `inputs` or `outputs` properties.
*/
hostDirectives?: (Type<unknown>|{
directive: Type<unknown>,
inputs?: string[],
outputs?: string[],
})[];
}

/**
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/render3/jit/directive.ts
Expand Up @@ -416,12 +416,8 @@ export function directiveMetadata(type: Type<any>, metadata: Directive): R3Direc
providers: metadata.providers || null,
viewQueries: extractQueriesMetadata(type, propMetadata, isViewQuery),
isStandalone: !!metadata.standalone,
hostDirectives:
// TODO(crisbeto): remove the `as any` usage here and down in the `map` call once
// host directives are exposed in the public API.
(metadata as any)
.hostDirectives?.map(
(directive: any) => typeof directive === 'function' ? {directive} : directive) ||
hostDirectives: metadata.hostDirectives?.map(
directive => typeof directive === 'function' ? {directive} : directive) ||
null
};
}
Expand Down