(target: TcbTargetInput, content?: string)
| 362 | } |
| 363 | |
| 364 | function adaptHostElement(target: TcbTargetInput, content?: string): TmplAstHostElement | null { |
| 365 | // We don't use the name for anything so just pass a dummy one. |
| 366 | const fileName = 'hostTcb.ts'; |
| 367 | const objectLiteralBindings: HostObjectLiteralBinding[] = []; |
| 368 | const hostBindingDecorators: HostBindingDecorator[] = []; |
| 369 | const hostListenerDecorators: HostListenerDecorator[] = []; |
| 370 | |
| 371 | for (const prop of target.hostProperties) { |
| 372 | if (!isStaticSourceNode(prop.key) || prop.value.kind !== 'string') { |
| 373 | continue; |
| 374 | } |
| 375 | |
| 376 | objectLiteralBindings.push({ |
| 377 | key: adaptSourceNode(prop.key, fileName, content), |
| 378 | value: adaptSourceNode(prop.value, fileName, content), |
| 379 | sourceSpan: createSpan(fileName, prop.key.sourceSpan.start, prop.value.sourceSpan.end), |
| 380 | }); |
| 381 | } |
| 382 | |
| 383 | for (const decorator of target.hostBindings) { |
| 384 | // ngtsc only type-checks `@HostBinding`s on property declarations; those on getters and |
| 385 | // setters are emitted but never reach the type-check block. |
| 386 | // https://github.com/angular/angular/blob/cda8962/packages/compiler-cli/src/ngtsc/annotations/directive/src/shared.ts#L681-L682 |
| 387 | if (decorator.isAccessor || !isStaticSourceNode(decorator.memberName)) { |
| 388 | continue; |
| 389 | } |
| 390 | |
| 391 | hostBindingDecorators.push({ |
| 392 | memberName: adaptSourceNode(decorator.memberName, fileName, content) as StaticSourceNode, |
| 393 | memberSpan: createSpan(fileName, decorator.memberSpan.start, decorator.memberSpan.end), |
| 394 | decoratorSpan: createSpan( |
| 395 | fileName, |
| 396 | decorator.decoratorSpan.start, |
| 397 | decorator.decoratorSpan.end, |
| 398 | ), |
| 399 | arguments: decorator.arguments.map((arg) => adaptSourceNode(arg, fileName, content)), |
| 400 | }); |
| 401 | } |
| 402 | |
| 403 | for (const decorator of target.hostListeners) { |
| 404 | const eventName = decorator.eventName; |
| 405 | |
| 406 | if (eventName?.kind !== 'string' || !isStaticSourceNode(decorator.methodName)) { |
| 407 | continue; |
| 408 | } |
| 409 | |
| 410 | hostListenerDecorators.push({ |
| 411 | eventName: adaptSourceNode(eventName, fileName, content) as StaticSourceNode, |
| 412 | memberName: adaptSourceNode(decorator.methodName, fileName, content) as StaticSourceNode, |
| 413 | memberSpan: createSpan(fileName, decorator.memberSpan.start, decorator.memberSpan.end), |
| 414 | decoratorSpan: createSpan( |
| 415 | fileName, |
| 416 | decorator.decoratorSpan.start, |
| 417 | decorator.decoratorSpan.end, |
| 418 | ), |
| 419 | arguments: decorator.args.map((arg) => adaptSourceNode(arg, fileName, content)), |
| 420 | }); |
| 421 | } |
no test coverage detected