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

Function isNativeField

packages/compiler/src/typecheck/ops/signal_forms.ts:372–394  ·  view source on GitHub ↗
(
  dir: TcbDirectiveMetadata,
  node: Node,
  allDirectiveMatches: TcbDirectiveMetadata[],
)

Source from the content-addressed store, hash-verified

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

Callers 1

appendDirectiveInputsMethod · 0.90

Calls 3

isFieldDirectiveFunction · 0.85

Tested by

no test coverage detected