src/lib/form/extractors/strategies/aria-label.ts

Total Symbols
1
Lines of Code
17
Avg Complexity
2.0
Avg Coverage
100.0%

Symbols by Kind

method 1

All Symbols

Name Kind Visibility Status Lines Signature
find method - 11-15 find(element: HTMLElement): : LabelResult | null

Full Source

/**
 * Label Strategy — aria-label
 *
 * Reads the WAI-ARIA `aria-label` attribute.
 */

import type { LabelResult, LabelStrategy } from "../label-strategy.interface";

export const ariaLabelStrategy: LabelStrategy = {
  name: "aria-label",
  find(element: HTMLElement): LabelResult | null {
    const ariaLabel = element.getAttribute("aria-label");
    const text = ariaLabel?.trim();
    return text ? { text, strategy: "aria-label" } : null;
  },
};