( dir: TcbDirectiveMetadata, node: Node, allDirectiveMatches: TcbDirectiveMetadata[], )
| 378 | |
| 379 | /** Determines if a directive usage is on a native field. */ |
| 380 | export function isNativeField( |
| 381 | dir: TcbDirectiveMetadata, |
| 382 | node: Node, |
| 383 | allDirectiveMatches: TcbDirectiveMetadata[], |
| 384 | ): node is Element & {name: 'input' | 'select' | 'textarea'} { |
| 385 | // Only applies to the `FormField` directive. |
| 386 | if (!isFieldDirective(dir)) { |
| 387 | return false; |
| 388 | } |
| 389 | |
| 390 | // Only applies to input, select and textarea elements. |
| 391 | if ( |
| 392 | !(node instanceof Element) || |
| 393 | (node.name !== 'input' && node.name !== 'select' && node.name !== 'textarea') |
| 394 | ) { |
| 395 | return false; |
| 396 | } |
| 397 | |
| 398 | // Only applies if there are no custom fields or ControlValueAccessors. |
| 399 | return allDirectiveMatches.every((meta) => { |
| 400 | return getCustomFieldDirectiveType(meta) === null && !isControlValueAccessorLike(meta); |
| 401 | }); |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Determines if a directive is shaped like a `ControlValueAccessor`. Note that this isn't |
no test coverage detected