Skip to content

Add role=image as synonym for role=img - #1370

Merged
jnurthen merged 5 commits into
mainfrom
issue758
May 6, 2021
Merged

Add role=image as synonym for role=img#1370
jnurthen merged 5 commits into
mainfrom
issue758

Conversation

@scottaohara

@scottaohara scottaohara commented Dec 15, 2020

Copy link
Copy Markdown
Member

Using none as a reference point, created a first draft of the image entry into the spec.

This initial commit only adds the note about why image is being added to the new image entry. Once we are happy with this note, we can add it to the img section as well... if we think that's necessary (they do show up right next to each other in the spec, after all).


Preview (#image) (#img) | Diff

@carmacleod carmacleod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than fixing up that one id, looks good to me!
Thanks, @scottaohara!

Comment thread index.html Outdated
@carmacleod

Copy link
Copy Markdown
Contributor

@cookiecrook I'm guessing that you will enjoy reviewing this one. ;)

Comment thread index.html Outdated
Co-authored-by: James Craig <cookiecrook@users.noreply.github.com>

@mcking65 mcking65 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scottaohara

Thank you for the addition!

Comment thread index.html Outdated
Comment thread index.html Outdated
Base automatically changed from master to main January 20, 2021 22:59
@carmacleod carmacleod linked an issue Mar 4, 2021 that may be closed by this pull request
@jnurthen

jnurthen commented Mar 4, 2021

Copy link
Copy Markdown
Member

fixes #758

@jnurthen jnurthen added the Agenda label Mar 4, 2021
@jnurthen

Copy link
Copy Markdown
Member

Decision in 25-Mar-2021 meeting - no fallback role

revise the wording per matt’s feedback.  Removed the paragraph on fallback per the decision the WG came to in the march 25th call.
@cookiecrook

Copy link
Copy Markdown
Contributor

https://webkit.org/b/224615

@jnurthen
jnurthen merged commit d75a248 into main May 6, 2021
jnurthen pushed a commit that referenced this pull request May 6, 2021
Co-authored-by: James Craig <cookiecrook@users.noreply.github.com>
@pkra
pkra deleted the issue758 branch January 10, 2022 16:53
@pkra pkra added this to the ARIA 1.3 milestone Jan 10, 2022
@pkra pkra mentioned this pull request Jan 10, 2022
@jcsteh

jcsteh commented Apr 21, 2023

Copy link
Copy Markdown
Contributor

@scottaohara

Copy link
Copy Markdown
Member Author

created a bug with chromium to get this implemented
cc @aleventhal @benbeaudry https://bugs.chromium.org/p/chromium/issues/detail?id=1463426

chutchins25 added a commit to dequelabs/axe-core that referenced this pull request Jul 29, 2026
Add a reusable synonym mechanism: the image role is defined as a synonym
of img (ARIA 1.3, w3c/aria#1370) and getExplicitRole/getRole resolve
synonym roles to their canonical role by default, with a noSynonym opt
out. The role-img-alt selector and aria-allowed-role role resolution are
updated so role=image behaves like role=img.

Closes #4656
chutchins25 added a commit to dequelabs/axe-core that referenced this pull request Jul 29, 2026
Add the ARIA 1.3 image role (w3c/aria#1370) as an alias of img: it is a
valid role sharing img's definition (spread from a common object) and is
allowed wherever img is allowed in the html-elms spec (embed, iframe,
svg). The role-img-alt selector matches both roles via :is().

This avoids a synonym-resolution mechanism, so the role the author used
is preserved when reporting an unallowed role.

Closes #4656
straker added a commit to dequelabs/axe-core that referenced this pull request Aug 3, 2026
Adds support for `role="image"` as a valid role equivalent to
`role="img"` (ARIA 1.3,
[w3c/aria#1370](w3c/aria#1370)).

## What & why

ARIA 1.3 adds `image` as an alias of `img` with an identical mapping;
axe previously treated `role="image"` as an invalid role.

Per the review discussion, this does **not** use a synonym-normalization
mechanism (which would force every reporting path to remember the role
the author used vs. the one our code resolved it to). Instead, `image`
is a first-class role that shares `img`'s definition and is allowed
wherever `img` is:

- `image` is added to `lib/standards/aria-roles.js`, spread from a
shared `imgRole` object so it stays in sync with `img`.
- `image` is added to every `html-elms` `allowedRoles` list that
includes `img` (`embed`, `iframe`, `object`). `svg` needs no change — it
is `allowedRoles: true`, so it already accepts any role.
- The `role-img-alt` and `svg-img-alt` selectors match both roles via
`:is([role='img'], [role='image'])`. Without the `svg-img-alt` change,
`<svg role="image">` matched neither rule — `svg-img-alt`'s selector
omitted it and `role-img-alt` is gated by `html-namespace-matches` — so
axe accepted the role and then never checked for an accessible name.
- `image` is added to the `aria-roledescription` check's
`supportedRoles`, so `role="image"` passes where `role="img"` does.

Because there is no synonym resolution, an unallowed `role="image"`
reports **`image`** (the role the author used), not `img`.

## Tests

- `is-valid-role` / `aria-roles` integration — `image` is a valid role.
- `get-element-unallowed-roles` — `image` allowed on
`svg`/`embed`/`object`/`iframe`; reported as authored when unallowed
(e.g. on `hr`).
- `role-img-alt` integration + virtual-rules — matches `role="image"`.
- `svg-img-alt` integration + virtual-rules — matches `role="image"`.
- `aria-roledescription` — `role="image"` passes against the check's
default `supportedRoles`.
- ACT specs `7d6734` and `23a2a8` still pass with the broadened
selectors.

## Not in scope

`role-img-alt` and `svg-img-alt` metadata still name only `img` in their
`description`/`help` strings. Updating them regenerates
`locales/_template.json`, invalidates those translations, and needs a
matching axe-rule-help change — tracked in #5272.

Closes #4656

---------

Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add role="image" as synonym for role="img"

8 participants