tryRole function ✓ 100.0%

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

Metrics

LOC: 19 Complexity: 5 Params: 1 Coverage: 100.0% (6/6 lines, 79x executed)

Signature

tryRole(el: Element): : SmartSelector | null

Source Code

function tryRole(el: Element): SmartSelector | null {
  const role = el.getAttribute("role");
  if (!role) return null;

  const name = el.getAttribute("aria-label") ?? el.getAttribute("name") ?? "";
  if (name) {
    return {
      value: `[role="${escapeCSS(role)}"][aria-label="${escapeCSS(name)}"]`,
      strategy: "role",
      description: `role="${role}" name="${name}"`,
    };
  }

  return {
    value: `[role="${escapeCSS(role)}"]`,
    strategy: "role",
    description: `role="${role}"`,
  };
}

Dependencies (Outgoing)

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

No incoming dependencies.