Follow-up from review of #5170 (comment).
The title-only check (lib/checks/label/title-only-evaluate.js) decides whether an element's only labeling comes from title/aria-describedby:
function titleOnlyEvaluate(node, options, virtualNode) {
const labelText = labelVirtual(virtualNode);
const title = titleText(virtualNode);
const ariaDescribedBy = virtualNode.attr('aria-describedby');
return !labelText && !!(title || ariaDescribedBy);
}
This is buggy (pre-existing, not introduced by #5170): it treats the mere presence of an aria-describedby attribute as an accessible description, without resolving the referenced elements or checking whether they actually contribute any text. An aria-describedby pointing at a missing/empty element yields no description, but this check still counts it.
Rather than patch the heuristic, we should build a proper accessibleDescription method — analogous to the existing accessible-name computation (accessibleText) — per the accname description algorithm, and use it here.
Tasks
- Add an
accessibleDescription helper (alongside accessible-name computation in commons/text) implementing the accessible description algorithm.
- Update
title-only (and other consumers of the title/aria-describedby presence heuristic) to use it.
- Cover with unit tests, including empty/missing
aria-describedby references.
Follow-up from review of #5170 (comment).
The
title-onlycheck (lib/checks/label/title-only-evaluate.js) decides whether an element's only labeling comes fromtitle/aria-describedby:This is buggy (pre-existing, not introduced by #5170): it treats the mere presence of an
aria-describedbyattribute as an accessible description, without resolving the referenced elements or checking whether they actually contribute any text. Anaria-describedbypointing at a missing/empty element yields no description, but this check still counts it.Rather than patch the heuristic, we should build a proper
accessibleDescriptionmethod — analogous to the existing accessible-name computation (accessibleText) — per the accname description algorithm, and use it here.Tasks
accessibleDescriptionhelper (alongside accessible-name computation incommons/text) implementing the accessible description algorithm.title-only(and other consumers of thetitle/aria-describedbypresence heuristic) to use it.aria-describedbyreferences.