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

View all

  • [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)

graph LR resolveLabel["resolveLabel"] buildCapturedActions["buildCapturedActions"] buildStep["buildStep"] buildCapturedActions -->|calls| resolveLabel buildStep -->|calls| resolveLabel style resolveLabel fill:#dbeafe,stroke:#2563eb,stroke-width:2px click resolveLabel "12990407e73ce2fe.html" click buildCapturedActions "f658aa776f85c9b9.html" click buildStep "6d1088fe63d8f4bc.html"
SourceType
buildCapturedActions calls
buildStep calls