src/lib/form/extractors/strategies/fieldset-legend.ts
Symbols by Kind
method
1
All Symbols
| Name | Kind | Visibility | Status | Lines | Signature |
|---|---|---|---|---|---|
| find | method | - | 11-17 | find(element: HTMLElement): : LabelResult | null |
Full Source
/**
* Label Strategy — fieldset-legend
*
* Finds the nearest <fieldset> ancestor and reads its <legend>.
*/
import type { LabelResult, LabelStrategy } from "../label-strategy.interface";
export const fieldsetLegendStrategy: LabelStrategy = {
name: "fieldset-legend",
find(element: HTMLElement): LabelResult | null {
const fieldset = element.closest("fieldset");
if (!fieldset) return null;
const legend = fieldset.querySelector("legend");
const text = legend?.textContent?.trim();
return text ? { text, strategy: "fieldset-legend" } : null;
},
};