deduplicateFields function ✓ 100.0%

Last updated: 2026-03-04T23:21:38.397Z

Metrics

LOC: 19 Complexity: 4 Params: 3 Coverage: 100.0% (6/6 lines, 0x executed)

Signature

deduplicateFields( nativeFields: FormField[], customFields: FormField[], ): : FormField[]

Summary

Removes native fields whose underlying element is already contained within a custom component wrapper. Adapter-detected fields take precedence because they carry richer context (label, options, etc.).

Source Code

function deduplicateFields(
  nativeFields: FormField[],
  customFields: FormField[],
): FormField[] {
  if (customFields.length === 0) return nativeFields;

  // Collect all custom wrapper elements
  const customWrappers = new Set(customFields.map((f) => f.element));

  const filtered = nativeFields.filter((nf) => {
    // If the native element is a descendant of any custom wrapper, skip it
    for (const wrapper of customWrappers) {
      if (wrapper.contains(nf.element)) return false;
    }
    return true;
  });

  return [...filtered, ...customFields];
}

No outgoing dependencies.

Impact (Incoming)

graph LR deduplicateFields["deduplicateFields"] detectAllFields["detectAllFields"] detectAllFieldsAsync["detectAllFieldsAsync"] detectAllFields -->|calls| deduplicateFields detectAllFieldsAsync -->|calls| deduplicateFields style deduplicateFields fill:#dbeafe,stroke:#2563eb,stroke-width:2px click deduplicateFields "10d773974adfc3cb.html" click detectAllFields "394718c982f136bb.html" click detectAllFieldsAsync "1b422b3353cdbe22.html"
SourceType
detectAllFields calls
detectAllFieldsAsync calls