createHostComponentMeta function

CompileDirectiveMetadata createHostComponentMeta(
  1. CompileTypeMetadata componentType,
  2. String componentSelector,
  3. AnalyzedClass? analyzedClass,
  4. bool? preserveWhitespace,
)

Construct CompileDirectiveMetadata from ComponentTypeMetadata and a selector.

Implementation

CompileDirectiveMetadata createHostComponentMeta(
    CompileTypeMetadata componentType,
    String componentSelector,
    AnalyzedClass? analyzedClass,
    bool? preserveWhitespace) {
  var template =
      CssSelector.parse(componentSelector)[0].getMatchingElementTemplate();
  return CompileDirectiveMetadata(
    originType: componentType,
    type: CompileTypeMetadata(
        name: '${componentType.name}Host',
        moduleUrl: componentType.moduleUrl,
        isHost: true),
    template: CompileTemplateMetadata(
        template: template,
        templateUrl: '${componentType.moduleUrl}/host/$componentSelector',
        preserveWhitespace: preserveWhitespace,
        styles: const [],
        styleUrls: const [],
        ngContentSelectors: const []),
    changeDetection: ChangeDetectionStrategy.checkAlways,
    analyzedClass: analyzedClass,
    inputs: const {},
    inputTypes: const {},
    outputs: const {},
    hostBindings: const {},
    hostListeners: const {},
    metadataType: CompileDirectiveMetadataType.component,
    selector: '*',
  );
}