问题
aria-expanded="bool"
is not support attribute that role="menuitem"
.
Please refer to W3C HTML Document. (https://www.w3.org/TR/html/)
If use that, get markup error on Nu Html Checker. But when I create some menu widget I must use it. And W3C use the same way in the formula example:
- https://www.w3.org/TR/2017/WD-wai-aria-practices-1.1-20170628/examples/menubar/menubar-1/menubar-1.html
- https://www.w3.org/WAI/tutorials/menus/application-menus-code/
What is right and what is wrong?
回答1:
As pointed out by the ARIA documentation
State and properties "Related Concepts", "Used in Roles", "Inherits into Roles" are Advisory information, but more important :
Use of a given state or property is not defined when used on roles other than those listed.
So, you have perfectly the right to use the aria-expanded
on a role=menuitem
element but the "Nu validator" is right as long as it emits a warning, not an error.
EDIT: HTML-ARIA documentation also specifies that section "3. Allowed ARIA roles, states and properties" is non-normative:
The following table provides an informative reference to the ARIA roles, states and properties permitted for use in HTML. All ARIA roles, states and properties are normatively defined in the ARIA 1.1 specification.
来源:https://stackoverflow.com/questions/44990967/about-use-aria-expanded-on-role-menuitem