{"id":22293534,"url":"https://github.com/xi/aria-api","last_synced_at":"2025-04-09T16:04:52.419Z","repository":{"id":49203811,"uuid":"84739420","full_name":"xi/aria-api","owner":"xi","description":"access ARIA information from JavaScript","archived":false,"fork":false,"pushed_at":"2024-11-01T13:09:21.000Z","size":385,"stargazers_count":35,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-09T16:04:48.145Z","etag":null,"topics":["a11y","aria","library"],"latest_commit_sha":null,"homepage":"","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/xi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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":"2017-03-12T16:17:30.000Z","updated_at":"2025-03-27T15:28:03.000Z","dependencies_parsed_at":"2024-06-19T00:26:32.211Z","dependency_job_id":"47262e6d-e27b-4d43-b1d0-34d695b044c1","html_url":"https://github.com/xi/aria-api","commit_stats":{"total_commits":251,"total_committers":3,"mean_commits":83.66666666666667,"dds":0.01195219123505975,"last_synced_commit":"e2aad8e20e26313de68ed1b4adfc8ba3e2627eb7"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xi%2Faria-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xi%2Faria-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xi%2Faria-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xi%2Faria-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xi","download_url":"https://codeload.github.com/xi/aria-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065289,"owners_count":21041871,"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":["a11y","aria","library"],"created_at":"2024-12-03T17:29:31.551Z","updated_at":"2025-04-09T16:04:52.401Z","avatar_url":"https://github.com/xi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aria-api\n\n[WAI-ARIA](https://www.w3.org/TR/wai-aria/) allows websites to provide\nadditional semantics to assistive technologies. Roles and attributes can be set\neither explicitly (e.g. `\u003cspan role=\"link\"\u003eclick me\u003c/span\u003e`) or implicitly\n(`\u003ca href=\"//example.com\"\u003eclick me\u003c/a\u003e` implicitly has the role \"link\").\n\nWhile the implicit mappings make authoring accessible websites simpler, it\nmakes the task of calculating an element's role and attributes more\ncomplicated. This library takes care of exactly that.\n\n## Install\n\n    npm install aria-api\n\nThis installation method works best if you use tools like webpack or\nrollup. There is also an UMD build included as `dist/aria.js`.\n\n# Usage\n\n    var aria = require('aria-api'):\n\n    aria.querySelector('landmark').forEach(landmark =\u003e {\n        if (!aria.matches(landmark, ':hidden')) {\n            var role = aria.getRole(landmark);\n            var name = aria.getName(landmark);\n            console.log(role, name);\n        }\n    });\n\n## getRole(element)\n\nCalculate an element's role.\n\nNote that this will return only the most specific role. If you want to know\nwhether an element *has* a role, use `matches()` instead.\n\n## getAttribute(element, attribute)\n\nCalculate the value of an element's attribute (state or property). The\n\"aria-\" prefix is not included in the attribute name.\n\n## getName(element)\n\nCalculate an element's name according to the [Accessible Name and Description\nComputation](https://www.w3.org/TR/accname-aam-1.1/#mapping_additional_nd_te).\n\n## getDescription(element)\n\nCalculate an element's description according to the [Accessible Name and\nDescription Computation](https://www.w3.org/TR/accname-aam-1.1/#mapping_additional_nd_te).\n\n## matches(element, selector)\n\nSimilar to [Element.matches()](https://developer.mozilla.org/en-US/docs/Web/API/Element/matches),\nthis allows to check whether an element matches a selector. A selector can be\nany of the following:\n\n-   `role`: Matches if the element has the specified role. This also works for\n    hierarchical roles such as \"landmark\".\n-   `:attribute`: Matches if the attribute is truthy. The \"aria-\" prefix is not\n    included in the attribute name.\n-   `[attribute=\"value\"]`: Matches if the value of the attribute converted to\n    string equals the specified value.\n\nNote that combinations of selectors are **not supported** (e.g. `main link`,\n`link:hidden`, `:not(:hidden)`).  The single exception to this rule are\ncomma-separated lists of roles, e.g. `link,button`.\n\n## querySelector(element, selector)\n\nSimilar to [Element.querySelector()](https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector).\nSee `matches()` for details.\n\n## querySelectorAll(element, selector)\n\nSimilar to [Element.querySelectorAll()](https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll).\nSee `matches()` for details.\n\n## closest(element, selector)\n\nSimilar to [Element.closest()](https://developer.mozilla.org/en-US/docs/Web/API/Element/closest).\nSee `matches()` for details.\n\n## getParentNode(node)\n\nSimilar to [Node.parentNode](https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode),\nbut takes `aria-owns` into account.\n\n## getChildNodes(node)\n\nSimilar to [Node.childNodes](https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes),\nbut takes `aria-owns` into account.\n\n# What is this for?\n\nFirst of all, I thought that something like this should exist. I currently use\nit for [a11y-outline](https://github.com/xi/a11y-outline/), a web extension\nthat generates outlines based on WAI-ARIA roles.\n\nThat said, this is what I think it could also be used for:\n\n-   Providing features based on the additional information provided by ARIA,\n    e.g. landmark navigation.\n-   Tools helping developers with improving accessibility.\n\n# Implemented standards\n\n-   [Accessible Rich Internet Applications 1.3](https://www.w3.org/TR/wai-aria-1.3/)\n-   [HTML Accessibility API Mappings 1.0](https://www.w3.org/TR/html-aam-1.0/)\n-   [SVG Accessibility API Mappings](https://www.w3.org/TR/svg-aam-1.0/)\n-   [WAI-ARIA Graphics Module 1.0](https://www.w3.org/TR/graphics-aria-1.0/)\n-   [Digital Publishing WAI-ARIA Module 1.1](https://www.w3.org/TR/dpub-aria-1.1/)\n-   [Accessible Name and Description Computation 1.2](https://www.w3.org/TR/accname-1.2/)\n\nI try to update the code whenever a new version of these specs becomes a\nrecommendation.\n\n# Notes\n\n-   This is a pet project. I do not have the time to do extensive testing and\n    may skip some details now and then. I am happy to receive bug reports and\n    pull requests though.\n-   The standards are still in a very rough state. Many things are\n    unclear/undecided and therefore no browser really implements them. So\n    naturally, this library cannot really implement the standards either.\n-   This library does not do any validity checks. Invalid attributes or roles\n    will not produce any warnings.\n-   In order to calculate the \"hidden\" attribute,\n    [Window.getComputedStyle()](https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle)\n    is called. This only seems to return reliable values if the element is\n    attached to `document`.\n-   Due to security restrictions it is not generally possible to inspect the\n    content of iframes, so they are ignored.\n\n# Related projects\n\n-   [Visual ARIA Bookmarklet](https://whatsock.github.io/visual-aria/github-bookmarklet/visual-aria.htm):\n    Displays role, name, and description in any website. Maintained by one of\n    the editors of the [accname]() spec.\n-   [axe-core](https://github.com/dequelabs/axe-core/) and\n    [Accessibility Developer Tools](https://github.com/GoogleChrome/accessibility-developer-tools):\n    These are libraries for accessibility testing. They solve many of the same\n    issues as this library internally.\n-   [ARIA Query](https://github.com/A11yance/aria-query):\n    Information from the ARIA spec as JavaScript structures.\n-   [Accessibility Object Model](https://wicg.github.io/aom/):\n    Draft spec for exposing the accessibility tree to JavaScript.\n-   [chrome.automation](https://developer.chrome.com/extensions/automation):\n    A propriatary API that exposes the accessibility tree to JavaScript.\n-   [babelacc](https://xi.github.io/babelacc/):\n    A tool to compare the output of different libraries.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxi%2Faria-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxi%2Faria-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxi%2Faria-api/lists"}