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

Function compileHostMetadata

packages/compiler/src/render3/partial/directive.ts:207–228  ·  view source on GitHub ↗

* Compiles the host metadata into its partial declaration form as declared * in `R3DeclareDirectiveMetadata['host']`

(meta: R3HostMetadata)

Source from the content-addressed store, hash-verified

205 * in `R3DeclareDirectiveMetadata['host']`
206 */
207function compileHostMetadata(meta: R3HostMetadata): o.LiteralMapExpr | null {
208 const hostMetadata = new DefinitionMap<NonNullable<R3DeclareDirectiveMetadata['host']>>();
209 hostMetadata.set(
210 'attributes',
211 toOptionalLiteralMap(meta.attributes, (expression) => expression),
212 );
213 hostMetadata.set('listeners', toOptionalLiteralMap(meta.listeners, o.literal));
214 hostMetadata.set('properties', toOptionalLiteralMap(meta.properties, o.literal));
215
216 if (meta.specialAttributes.styleAttr) {
217 hostMetadata.set('styleAttribute', o.literal(meta.specialAttributes.styleAttr));
218 }
219 if (meta.specialAttributes.classAttr) {
220 hostMetadata.set('classAttribute', o.literal(meta.specialAttributes.classAttr));
221 }
222
223 if (hostMetadata.values.length > 0) {
224 return hostMetadata.toLiteralMap();
225 } else {
226 return null;
227 }
228}
229
230function createHostDirectives(
231 hostDirectives: NonNullable<R3DirectiveMetadata['hostDirectives']>,

Callers 1

Calls 3

setMethod · 0.95
toLiteralMapMethod · 0.95
toOptionalLiteralMapFunction · 0.90

Tested by

no test coverage detected