Skip to content

Commit eedfa8f

Browse files
authored
AAM improvements (#40)
* AAM improvements * Update deps
1 parent 047714d commit eedfa8f

22 files changed

+829
-709
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"html-aria": patch
3+
---
4+
5+
Bugfix: more AAM mappings were incorporated
6+
7+
- `<dd>` now maps to `definition`
8+
- `<dt>` now maps to `term`
9+
- `<figcaption>` now maps to `caption`

.changeset/silly-tigers-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"html-aria": patch
3+
---
4+
5+
Add support for custom elements

.changeset/two-toys-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"html-aria": minor
3+
---
4+
5+
Bugfix: aria-roledescription and aria-brailleroledescription removed from “naming prohibited” attributes

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Determine which HTML maps to which default ARIA role.
118118
import { getRole } from "html-aria";
119119

120120
// DOM
121-
const el = document.querySelector('article')
121+
const el = document.querySelector("article");
122122
getRole(el); // "article"
123123

124124
// Node.js (no DOM)
@@ -142,7 +142,7 @@ The spec dictates that **certain elements may NOT receive certain roles.** For e
142142
import { getSupportedRoles } from "html-aria";
143143

144144
// DOM
145-
const el = document.querySelector('img')
145+
const el = document.querySelector("img");
146146
getSupportedRoles(el); // ["none", "presentation", "img"]
147147

148148
// Node.js (no DOM)
@@ -341,13 +341,19 @@ Further, a common mistake many simple accessibility libraries make is mapping ar
341341

342342
_Note: `` = [no corresponding role](#whats-the-difference-between-no-corresponding-role-and-the-none-role). Also worth pointing out that in other cases, [global aria-\* attributes](https://www.w3.org/TR/wai-aria-1.3/#global_states) are allowed, so this is unique to the element and NOT the ARIA role._
343343

344-
### Technical deviations from the spec
344+
### Discrepancies between specs
345345

346-
#### Mark
346+
Though the [HTML in ARIA](https://www.w3.org/TR/html-aria) spec was the foundation for this library, at points it conflicts with [AAM](https://www.w3.org/TR/html-aam-1.0). We also have browsers sometimes showing inconsistent roles, too. For these discrepancies, we compare what the specs recommend, along with the library’s current decision in an attempt to follow the most helpful path.
347347

348-
The `<mark>` tag gets the `mark` role. Seems logical, right? Well, not according to the spec. It’s [not listed in the HTML in ARIA spec](https://www.w3.org/TR/html-aria/#el-mark), and it’s worth noting that `<mark>` is a [_related concept_](https://www.w3.org/TR/wai-aria-1.3/#mark), not a base concept as elements usually are.
348+
| Element | [HTML in ARIA](https://www.w3.org/TR/html-aria) | [AAM](https://www.w3.org/TR/html-aam-1.0) | Browsers\* | html-aria |
349+
| :------------- | :---------------------------------------------- | :---------------------------------------- | :------------------------------- | --------------------- |
350+
| `<dd>` | No corresponding role | definition | definition | definition |
351+
| `<dl>` | No corresponding role | list | (inconsistent) | No corresponding role |
352+
| `<dt>` | No corresponding role | term | term | term |
353+
| `<figcaption>` | No corresponding role | caption | caption (`Figcaption` in Chrome) | caption |
354+
| `<mark>` | No corresponding role | mark | mark | mark |
349355

350-
But despite the ARIA specs being pretty clear that `<mark>` and `mark` aren’t directly equivalent, all modern browsers today seem to think they are, and `<mark>` always gets a `mark` role. For that reason, html-aria has sided with practical browser implementation rather than the ARIA spec.
356+
_\* Chrome 132, Safari 18, Firefox 135. _
351357

352358
#### SVG
353359

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@
5252
"@changesets/changelog-github": "^0.5.0",
5353
"@changesets/cli": "^2.27.12",
5454
"@types/aria-query": "^5.0.4",
55-
"@vitest/browser": "^3.0.4",
55+
"@vitest/browser": "^3.0.5",
5656
"aria-query": "^5.3.2",
5757
"dom-accessibility-api": "^0.7.0",
58-
"happy-dom": "^16.7.3",
58+
"happy-dom": "^17.0.2",
5959
"jsdom": "^25.0.1",
60-
"playwright": "^1.50.0",
60+
"playwright": "^1.50.1",
6161
"typescript": "^5.7.3",
6262
"unbuild": "^3.3.1",
63-
"vitest": "^3.0.4"
63+
"vitest": "^3.0.5"
6464
}
6565
}

0 commit comments

Comments
 (0)