WebAIM - Web Accessibility In Mind

E-mail List Archives

Thread: Is it okay to change ARIA role with JavaScript after page load?

for

Number of posts in this thread: 1 (In chronological order)

From: Robert Fentress
Date: Mon, Jul 30 2018 10:19AM
Subject: Is it okay to change ARIA role with JavaScript after page load?
No previous message | No next message

I thought I'd remembered reading somewhere that best practice was not to
change the role of an existing element using JavaScript after the page has
loaded, but, rather, to recreate the element with the new role. However, I
can't seem to find where I'd read that initially or what exactly the
justification was for that. Certainly, unless JavaScript is intrinsic to
the functioning of the resource, progressive enhancement would suggest that
for any interactive widget role, you should not include the role inline.
This is because without scripting, the user may be presented with incorrect
cues and affordances. The Using ARIA Editor's Draft
<https://w3c.github.io/using-aria/#inline> seems to suggest the role should
be added with JavaScript, but doesn't say anything about needing to
recreate the element to do so.

So, is this actually an issue and why? Is it because the Accessibility
Tree is not always updated reliably if you change roles with JavaScript?
Or perhaps screen readers that don't access the Accessibility APIs directly
may not track these changes? If so, which assistive technologies might
still have this problem?

Thanks!

Best,
Rob

--
*Rob Fentress*
*Web Accessibility Solutions Designer*
Accessible Technologies at Virginia Tech
Electronic Business Card (vCard)
<http://search.vt.edu/search/person.vcf?person=1154847>;
LinkedIn Profile
<https://www.linkedin.com/in/rob-fentress-aa0b609?trk=profile-badge>
VT Zoom Personal Conferencing <https://virginiatech.zoom.us/my/rob.fentress>