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
- [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)
| Target | Type |
|---|---|
| getOwnDropdown | calls |
Impact (Incoming)
| Source | Type |
|---|---|
| selectOption | calls |