Skip to content

Commit c3d78b9

Browse files
committed
Add null alt element to icon img in HTML output
To improve accessibility
1 parent 5fdc53f commit c3d78b9

File tree

3 files changed

+34
-70
lines changed

3 files changed

+34
-70
lines changed

package-lock.json

Lines changed: 23 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/license-utilities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function generateLicenseLink(licenseIcons, licenseUrl, licenseName) {
262262
const iconSrc = attr =>
263263
`${ICON_BASE_URL}/${attr.toLowerCase()}.svg${assetPathRef}`;
264264
const icons = licenseIcons
265-
.map(attr => `<img ${iconStyle} src="${iconSrc(attr)}">`)
265+
.map(attr => `<img ${iconStyle} src="${iconSrc(attr)}" alt="">`)
266266
.join('');
267267

268268
const linkHref = `href="${licenseUrl}${assetPathRef}"`;

tests/unit/specs/components/LicenseHTML.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ describe('LicenseHTML.vue', () => {
5555

5656
const licenseIcons = wrapper.findAll('img');
5757
expect(licenseIcons.length).toBe(2);
58+
// Icon img elements should have the following attributes: source, style and alt
59+
const licenseIconsArray = licenseIcons.wrappers;
60+
licenseIconsArray.forEach((img) => {
61+
expect(Object.keys(img.attributes()).length).toBe(3);
62+
});
5863
});
5964

6065
it('has correct information when all attribution data is provided', async () => {
@@ -96,5 +101,10 @@ describe('LicenseHTML.vue', () => {
96101

97102
const licenseIcons = wrapper.findAll('img');
98103
expect(licenseIcons.length).toBe(2);
104+
// Icon img elements should have the following attributes: source, style and alt
105+
const licenseIconsArray = licenseIcons.wrappers;
106+
licenseIconsArray.forEach((img) => {
107+
expect(Object.keys(img.attributes()).length).toBe(3);
108+
});
99109
});
100110
});

0 commit comments

Comments
 (0)