SonarCloud analysis is complaining about an <li role="none">
element: "Elements with ARIA roles must use a valid, non-abstract ARIA role. "none" is not a valid role."
I can't find any information explaining why "none" would be considered invalid or abstract.
Why would "none" not be considered valid?
none
is a valid value for the role
attribute. It was introduced in WAI-ARIA 1.1 as a synonym for role="presentation"
. Both values have the same effect, namely removing an element's native semantics. (role="none"
was introduced because there were misunderstandings about the meaning of `role="presentation"´.)
In a regular list, role="none"
or role="presentation"
would not be valid. However, if you are using list markup for a menu, <li role="none">
is very common, since the <a>
elements inside <li role="none">
usually get a menuitem
role.
At the time of writing, Sonar (Sonar Cloud, Sonar Lint etc) has some accessibility checks, but these are still limited and imperfect. Flagging <li role="none">
without checking whether this code is used in something like <ul role="menu">
can easily lead to false positives. This looks like something that should be reported as a false positive on Sonar Community.