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

Function directiveMetadata

packages/core/src/render3/jit/directive.ts:377–409  ·  view source on GitHub ↗
(type: Type<any>, metadata: Directive)

Source from the content-addressed store, hash-verified

375 * `Component`).
376 */
377export function directiveMetadata(type: Type<any>, metadata: Directive): R3DirectiveMetadataFacade {
378 // Reflect inputs and outputs.
379 const reflect = getReflect();
380 const propMetadata = reflect.ownPropMetadata(type);
381
382 return {
383 name: type.name,
384 // g3-only legacyOptionalChaining: true,
385 legacyOptionalChaining: false, // 3p-only
386 type: type,
387 selector: metadata.selector !== undefined ? metadata.selector : null,
388 host: metadata.host || EMPTY_OBJ,
389 propMetadata: propMetadata,
390 inputs: metadata.inputs || EMPTY_ARRAY,
391 outputs: metadata.outputs || EMPTY_ARRAY,
392 queries: extractQueriesMetadata(type, propMetadata, isContentQuery),
393 lifecycle: {usesOnChanges: reflect.hasLifecycleHook(type, 'ngOnChanges')},
394 // Indicate that this directive requires the `ɵɵcontrolCreate` instruction to be generated.
395 controlCreate: reflect.hasLifecycleHook(type, 'ɵngControlCreate')
396 ? {passThroughInput: null}
397 : null,
398 typeSourceSpan: null!,
399 usesInheritance: !extendsDirectlyFromObject(type),
400 exportAs: extractExportAs(metadata.exportAs),
401 providers: metadata.providers || null,
402 viewQueries: extractQueriesMetadata(type, propMetadata, isViewQuery),
403 isStandalone: metadata.standalone === undefined ? true : !!metadata.standalone,
404 hostDirectives:
405 metadata.hostDirectives?.map((directive) =>
406 typeof directive === 'function' ? {directive} : directive,
407 ) || null,
408 };
409}
410
411/**
412 * Adds a directive definition to all parent classes of a type that don't have an Angular decorator.

Callers 3

directive_spec.tsFile · 0.90
compileComponentFunction · 0.85
getDirectiveMetadataFunction · 0.85

Calls 7

getReflectFunction · 0.90
extractQueriesMetadataFunction · 0.85
extractExportAsFunction · 0.85
ownPropMetadataMethod · 0.80
mapMethod · 0.80
hasLifecycleHookMethod · 0.65

Tested by

no test coverage detected