tryAriaLabel function ✓ 100.0%

Last updated: 2026-03-05T12:26:14.062Z

Metrics

LOC: 23 Complexity: 4 Params: 1 Coverage: 100.0% (9/9 lines, 79x executed)

Signature

tryAriaLabel(el: Element): : SmartSelector | null

Source Code

function tryAriaLabel(el: Element): SmartSelector | null {
  const label = el.getAttribute("aria-label");
  if (label) {
    return {
      value: `[aria-label="${escapeCSS(label)}"]`,
      strategy: "aria-label",
      description: `aria-label="${label}"`,
    };
  }

  const labelledBy = el.getAttribute("aria-labelledby");
  if (labelledBy) {
    const labelEl = el.ownerDocument.getElementById(labelledBy);
    if (labelEl?.textContent?.trim()) {
      return {
        value: `[aria-labelledby="${escapeCSS(labelledBy)}"]`,
        strategy: "aria-label",
        description: `aria-labelledby → "${labelEl.textContent.trim()}"`,
      };
    }
  }
  return null;
}

Dependencies (Outgoing)

graph LR tryAriaLabel["tryAriaLabel"] escapeCSS["escapeCSS"] tryAriaLabel -->|calls| escapeCSS style tryAriaLabel fill:#dbeafe,stroke:#2563eb,stroke-width:2px click tryAriaLabel "7a8f51fc769eb549.html" click escapeCSS "44646aa96f30257e.html"
TargetType
escapeCSS calls

No incoming dependencies.