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)
| Target | Type |
|---|---|
| escapeCSS | calls |
No incoming dependencies.