findMatchingOption function infrastructure ✓ 88.9%

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

Metrics

LOC: 20 Complexity: 11 Params: 1 Coverage: 88.9% (8/9 lines, 0x executed)

Signature

findMatchingOption(val: string): : HTMLElement | null

Summary

Try to find an option matching val in THIS wrapper's dropdown. Strategy: exact match first, then word-boundary prefix match. Word-boundary avoids false positives like "TO" matching "Mato Grosso".

Architecture violations

View all

  • [warning] max-cyclomatic-complexity: 'findMatchingOption' has cyclomatic complexity 11 (max 10)

Source Code

  function findMatchingOption(val: string): HTMLElement | null {
    if (!val) return null;
    const norm = val.toLowerCase();
    const prefixRe = new RegExp(
      `\\b${val.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`,
      "i",
    );
    const dd = getOwnDropdown();
    if (!dd) return null;
    const options = dd.querySelectorAll<HTMLElement>(".ant-select-item-option");
    for (const opt of options) {
      const t = opt.getAttribute("title") ?? opt.textContent?.trim() ?? "";
      if (t.toLowerCase() === norm) return opt;
    }
    for (const opt of options) {
      const t = opt.getAttribute("title") ?? opt.textContent?.trim() ?? "";
      if (prefixRe.test(t)) return opt;
    }
    return null;
  }

Dependencies (Outgoing)

graph LR findMatchingOption["findMatchingOption"] getOwnDropdown["getOwnDropdown"] findMatchingOption -->|calls| getOwnDropdown style findMatchingOption fill:#dbeafe,stroke:#2563eb,stroke-width:2px click findMatchingOption "fca1c8c5a316b388.html" click getOwnDropdown "2e86cf83ed949de3.html"
TargetType
getOwnDropdown calls

Impact (Incoming)

graph LR findMatchingOption["findMatchingOption"] selectOption["selectOption"] selectOption -->|calls| findMatchingOption style findMatchingOption fill:#dbeafe,stroke:#2563eb,stroke-width:2px click findMatchingOption "fca1c8c5a316b388.html" click selectOption "fe5ab67a02962060.html"
SourceType
selectOption calls