resolveLabel function ✓ 100.0%
Last updated: 2026-03-05T11:49:57.418Z
Metrics
LOC: 28
Complexity: 11
Params: 1
Coverage: 100.0% (10/10 lines, 0x executed)
Signature
resolveLabel(el: Element): : string | undefined
Architecture violations
- [warning] max-cyclomatic-complexity: 'resolveLabel' has cyclomatic complexity 11 (max 10)
Source Code
function resolveLabel(el: Element): string | undefined {
if (
el instanceof HTMLInputElement ||
el instanceof HTMLSelectElement ||
el instanceof HTMLTextAreaElement
) {
const id = el.id;
if (id) {
const labelEl = document.querySelector(`label[for="${CSS.escape(id)}"]`);
if (labelEl?.textContent?.trim()) return labelEl.textContent.trim();
}
}
// Try closest label ancestor
const parentLabel = el.closest("label");
if (parentLabel?.textContent?.trim()) return parentLabel.textContent.trim();
// aria-label
const ariaLabel = el.getAttribute("aria-label");
if (ariaLabel) return ariaLabel;
// placeholder
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
if (el.placeholder) return el.placeholder;
}
return undefined;
}
No outgoing dependencies.
Impact (Incoming)
| Source | Type |
|---|---|
| buildCapturedActions | calls |
| buildStep | calls |