vakata / jstree

jquery tree plugin
http://jstree.com
MIT License
5.15k stars 1.38k forks source link

Forbidden attributes 'aria-selected' and 'aria-level' for <li> element with 'presentation' role. #2431

Closed Karkhutvy closed 4 years ago

Karkhutvy commented 4 years ago

Hi, I'm using AXE detection tool(https://www.deque.com/axe/) to detect accesibility issues. After updating to jsTree 3.3.10 I'm receiving warnings about forbidded attributes for tree elements:

"Ensures ARIA attributes are allowed for an element's role","help":"Elements must only use allowed ARIA attributes","helpUrl":"https://dequeuniversity.com/rules/axe/3.2/aria-allowed-attr?application=webdriverjs","id":"aria-allowed-attr","impact":"critical","nodes":[{"all":[],"any":[

{"data":["aria-selected=\"false\"","aria-level=\"1\""],"id":"aria-allowed-attr","impact":"critical","message":"ARIA attributes are not allowed: aria-selected=\"false\" aria-level=\"1\"","relatedNodes":[]}],"failureSummary":"Fix any of the following:\n ARIA attributes are not allowed: aria-selected=\"false\" aria-level=\"1\"","html":"<li role=\"presentation\"

It seems we have this issue because of <li> element that has role "presentation" but contains aria-selected and aria-level attributes. These attrbutes are not allowed for role "presentation". Maybe, role "treeitem" is expected for <li>elements instead of "presentation" or aria-selected and aria-level should be removed from <li>elements( because these attributes are already presented in inner <a> elements for jsTree 3.3.10).

vakata commented 4 years ago

Have you tried modifying the markup in the suggested way - will that get rid of errors? And does it cause any problems with actual screen readers?

Karkhutvy commented 4 years ago

I tried to modify the markup, and the problem was gone if change the role back to "treeitem". But in this case, we will have problems with the incorrect numbers and ordinal numbers of elements in the tree https://github.com/vakata/jstree/issues/2424. Another way to fix this is to remove aria-attributes from li elements and leave them only for a elements. I described this solution in comment section of https://github.com/vakata/jstree/issues/2424.