Skip to content

title-only check approximates accessible description; build a proper accessibleDescription method #5212

Description

@chutchins25

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixBug fixestech debtTechnical debt related tasks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions