Module: Dommy::Internal::AccessibleName

Defined in:
lib/dommy/internal/accessible_name.rb

Overview

Computes an element's WAI-ARIA accessible name (the "accname" algorithm) — what WPT's test_driver.get_computed_label returns and Testing Library's name option matches. A focused implementation covering the common steps: aria-labelledby, aria-label, native host-language labels (

Constant Summary collapse

NAME_FROM_CONTENT =

Roles whose accessible name may come from descendant content. (term / definition are nameFrom:author per ARIA, so they are NOT here.)

%w[
  button cell checkbox columnheader comment gridcell heading
  link menuitem menuitemcheckbox menuitemradio option radio row rowheader
  sectionhead suggestion switch tab tooltip treeitem
].freeze
LABELABLE =

Form controls whose name can come from an associated

%w[button input meter output progress select textarea].freeze
PLACEHOLDER_TYPES =

Input types for which the placeholder contributes the accessible name (the text-like inputs); type=number / range / date / … do not.

%w[text search tel url email password].freeze
BLOCK_TAGS =

Elements that generate a block-level box by the UA stylesheet — used as the fallback when no CSS layer is available to compute display.

%w[
  address article aside blockquote caption dd details div dl dt fieldset
  figcaption figure footer form h1 h2 h3 h4 h5 h6 header hr legend li main
  menu nav ol p pre section summary table tbody td tfoot th thead tr ul
].freeze

Class Method Summary collapse