{"id":15388777,"url":"https://github.com/hellogreg/getariarole","last_synced_at":"2026-02-23T08:30:25.694Z","repository":{"id":169492514,"uuid":"645437293","full_name":"hellogreg/getAriaRole","owner":"hellogreg","description":"getAriaRole is a bit of JavaScript that returns the current computed aria role for a specified element.","archived":false,"fork":false,"pushed_at":"2024-02-12T15:02:05.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-18T11:12:14.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hellogreg.github.io/getAriaRole/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hellogreg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-25T16:43:35.000Z","updated_at":"2023-05-26T14:36:19.000Z","dependencies_parsed_at":"2024-02-12T16:30:53.535Z","dependency_job_id":"244a00a2-ca39-4072-98e3-d3e294562589","html_url":"https://github.com/hellogreg/getAriaRole","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"fca601c37e8c6da3d285ce20e8ca6dde35d375ea"},"previous_names":["hellogreg/get-aria-role"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellogreg%2FgetAriaRole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellogreg%2FgetAriaRole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellogreg%2FgetAriaRole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellogreg%2FgetAriaRole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellogreg","download_url":"https://codeload.github.com/hellogreg/getAriaRole/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239858996,"owners_count":19708857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T14:58:15.554Z","updated_at":"2026-02-23T08:30:25.497Z","avatar_url":"https://github.com/hellogreg.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# getAriaRole\n\n[View the demo page](https://hellogreg.github.io/getAriaRole/)\n\n## Overview\n\nin the course of accessibility work, there are cases where it could be handy to know what implicit or computed ARIA role an element has. Unfortunately, there's no native way to get this value with JavaScript in most browsers.\n\n(_Explicitly_ declared roles can be gleaned via `element.role` or `element.getAttribute(\"role\")`.)\n\nChromium does have the [computedRole property](https://chromestatus.com/feature/5530552681627648) for elements, but it's behind a flag -- and they apparently [don't plan on unflagging it](https://bugs.chromium.org/p/chromium/issues/detail?id=442978). This property also may not be reliable in all cases (e.g., it can return a `gridcell` role value for `td` elements by default, even when the `td` is in a `table` without a `grid` role).\n\n**getAriaRole** comprises the following three global functions:\n\n- getAriaRole(_element_):\n- getImplicitRole(_element_)\n- getExplicitRole(_element_)\n\ngetAriaRole() returns the current ARIA role of an element. If the element has an explicit role, it uses that. If not, then it uses the implicit role.\n\nImplicit roles have been gathered from the W3C's [HTML Element Role Mappings](https://www.w3.org/TR/html-aam-1.0/#html-element-role-mappings), current as of 5/19/2023.\n\n## Usage\n\nAfter including the script in your project (e.g., via `\u003cscript src=\"getAriaRole.js\"\u003e` in an HTML file), you can call it for any element, like so:\n\n```\nconst element = document.getElementByID(\"some-element\");\n\n// Get the default role for the selected element.\nconst implicitRole = getImplicitRole(element);\n\n// Get the role attribute value for this element (if any, else undefined).\nconst explicitRole = getExplicitRole(element);\n\nGet the current computed aria role for the element.\nconst ariaRole = getAriaRole(element);\n\nconsole.log(`${element.id} implicit role: ${implicitRole}`);\nconsole.log(`${element.id} explicit role: ${explicitRole}`);\nconsole.log(`${element.id} computed aria role: ${ariaRole}`);\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellogreg%2Fgetariarole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellogreg%2Fgetariarole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellogreg%2Fgetariarole/lists"}