Example 1 — Read ariaRoleDescription
Log the current custom role description from a widget.
const el = document.getElementById("myApplication");
console.log(el.ariaRoleDescription);
// "a description of this widget"
// HTML: role="application" aria-roledescription="…" How It Works
- Find the element.
getElementByIdreturns the application widget node. - Read the reflection.
ariaRoleDescriptionreturns thearia-roledescriptionstring. - Keep the real role.
role="application"still defines the interaction model. - Missing attribute. If unset, many browsers return
null.

