-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(aria-allowed-attr): pass aria-label on some HTML elements #2935
Conversation
Allow aria-label and aria-labelledby on the following elements, if those elements have no role. - audio - applet - canvas - dl - embed - iframe - input - label - meter - object - span - svg - video
doc/check-options.md
Outdated
"label", | ||
"meter", | ||
"object", | ||
"span", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think span
should be allowed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@straker Are you able to link to the specific section of the ARIA spec that disallows aria-label
on span
? I'm looking through https://www.w3.org/TR/html-aria/, but I can't find anything that disallows it. It appears as though span
allows "Global aria-* attributes", of which aria-label
is one (per https://www.w3.org/TR/wai-aria-1.2/#global_states). Of course that list has the carve-out "Except where prohibited" for aria-label
, but I can't find anything that prohibits aria-label
for span
or more generally for role-less elements.
FWIW, I generally agree with disallowing aria-label
on span
, but I'm not sure if it's a strict ARIA conformance violation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there is no spec documented reason for this (although it's coming). You can see where we got most of the concept in this pr #2764. As it stands though, it's also a mix of a best practice since no screen reader supports it (#2712 (comment)).
Edit: looks like it's been updated since I last looked. The generic role now prevents aria-label/ledby.
02f41d5
to
bd072b2
Compare
bd072b2
to
6c9bc79
Compare
07aab35
to
332d338
Compare
332d338
to
d0087cf
Compare
* fix(aria-allowed-attr): pass aria-label on some HTML elements Allow aria-label and aria-labelledby on the following elements, if those elements have no role. - audio - applet - canvas - dl - embed - iframe - input - label - meter - object - span - svg - video * chore: Deal with IE * chore: Address feedback * chore: Maybe like this... * chore: Random guessing stuff * chore: Update doc/check-options.md
I'm seeing the same issue on an Markup that is failing:
Message from Axe:
|
@andrewleith |
Interesting. Thanks for the info @straker :) |
I'm not sure what you mean by formally, but Leonie Watson wrote an excellent article on this behavior, which was the basis of this rule. |
@straker @WilcoFiers Someone on the A11y Slack (external) channel today mentioned getting an error for aria-labelledby on a |
Allow aria-label and aria-labelledby on the following elements, if those elements have no role.
Closes issue: #2933, #2926
I did a bunch of testing with JAWS, NVDA and VoiceOver to come to this list, here are my test results:
https://codepen.io/wilcofiers/pen/WNpwMNj?editors=1000
"label" is the only one that isn't supported that I added anyway, because if you do
<label aria-label="foo" for="bar"></label>
, that label will be used in the accessible name of whatever form control hasid="bar"
.dl
is on the list (unlike ul, and ol) because it doesn't have an implicit role.