Skip to content

fix(aria-prohibited-attr): allow aria-label/labelledby on form - #5254

Closed
chutchins25 wants to merge 1 commit into
chut/3410-body-label-prohibitfrom
chut/5244-global-attr-audit
Closed

fix(aria-prohibited-attr): allow aria-label/labelledby on form#5254
chutchins25 wants to merge 1 commit into
chut/3410-body-label-prohibitfrom
chut/5244-global-attr-audit

Conversation

@chutchins25

Copy link
Copy Markdown
Contributor

Extends the #5185 fix to the form element, which has the same false positive.

Stacked PR — targets chut/3410-body-label-prohibit (#3410), which is itself stacked on #5185. GitHub will auto-retarget as the parents merge.

What & why

Follow-up to #5244 / #5185. An unnamed <form> resolves to a null role in axe (implicit-html-roles.js: hasAccessibleName(vNode) ? 'form' : null), so aria-prohibited-attr wrongly prohibited aria-label/aria-labelledby on <form aria-labelledby="…"> with an empty/unresolved reference.

Per ARIA in HTML (#el-form): the form element allows Global aria-* attributes, and "A form is not exposed as a landmark region unless it has been provided an accessible name."

Audit result

I audited implicit-html-roles.js for the name-dependent-null-role pattern. Only section, aside (fixed in #5185) and form match. header/footer map to null based on ancestor (not accessible name), and a scoped <footer>/<header> is exposed as generic — which prohibits naming — so flagging those is correct and they are intentionally excluded.

Fix

Add form to the elementsAllowedAriaLabel option (named forms already pass via the form landmark role).

Tests

  • aria-prohibited-attr check unit — form with empty aria-labelledby; named form.
  • aria-prohibited-attr integration — form with empty aria-labelledby pass case.
  • doc/check-options.md default updated.

Closes #5244

An unnamed form resolves to a null role but is still allowed global
aria-* attributes per ARIA in HTML. Add form to the
elementsAllowedAriaLabel option so an empty aria-label/aria-labelledby is
no longer prohibited.

Closes #5244

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chutchins25

Copy link
Copy Markdown
Contributor Author

Superseded by #5259. Its general mechanism already allows naming on an unnamed form (the role resolves to the implicit role and form isn't namingProhibited), so the dedicated form addition here isn't needed. Closing — #5259 covers the #5244 case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant