Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff41732

Browse files
committed
img with alt maps to image
according to https://www.w3.org/TR/html-aria/ and https://www.w3.org/TR/html-aam-1.0/, only images with `alt` explicitly set will map to `img` role.
1 parent d21a25e commit ff41732

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/rules/role-supports-aria-props.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ module.exports = {
4444
// - Get the element’s name
4545
const key = {name: getElementType(context, node)}
4646
// - Get the element’s disambiguating attributes
47-
for (const prop of ['aria-expanded', 'type', 'size', 'role', 'href', 'multiple', 'scope']) {
47+
for (const prop of ['alt', 'aria-expanded', 'type', 'size', 'role', 'href', 'multiple', 'scope']) {
4848
// - Only provide `aria-expanded` when it’s required for disambiguation
4949
if (prop === 'aria-expanded' && key.name !== 'summary') continue
50+
if (prop === 'alt' && key.name !== 'img') continue
5051
const value = getPropValue(getProp(node.attributes, prop))
5152
if (value) {
5253
if (!('attributes' in key)) {
5354
key.attributes = []
5455
}
55-
if (prop === 'href') {
56+
if (prop === 'href' || prop === 'alt') {
5657
key.attributes.push({name: prop})
5758
} else {
5859
key.attributes.push({name: prop, value})

0 commit comments

Comments
 (0)