Skip to content

Commit

Permalink
Add null alt element to icon img in HTML output
Browse files Browse the repository at this point in the history
To improve accessibility
  • Loading branch information
dijitali committed Apr 5, 2024
1 parent 5fdc53f commit c3d78b9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 70 deletions.
92 changes: 23 additions & 69 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/utils/license-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function generateLicenseLink(licenseIcons, licenseUrl, licenseName) {
const iconSrc = attr =>
`${ICON_BASE_URL}/${attr.toLowerCase()}.svg${assetPathRef}`;
const icons = licenseIcons
.map(attr => `<img ${iconStyle} src="${iconSrc(attr)}">`)
.map(attr => `<img ${iconStyle} src="${iconSrc(attr)}" alt="">`)
.join('');

const linkHref = `href="${licenseUrl}${assetPathRef}"`;
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/specs/components/LicenseHTML.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ describe('LicenseHTML.vue', () => {

const licenseIcons = wrapper.findAll('img');
expect(licenseIcons.length).toBe(2);
// Icon img elements should have the following attributes: source, style and alt
const licenseIconsArray = licenseIcons.wrappers;
licenseIconsArray.forEach((img) => {
expect(Object.keys(img.attributes()).length).toBe(3);
});
});

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

const licenseIcons = wrapper.findAll('img');
expect(licenseIcons.length).toBe(2);
// Icon img elements should have the following attributes: source, style and alt
const licenseIconsArray = licenseIcons.wrappers;
licenseIconsArray.forEach((img) => {
expect(Object.keys(img.attributes()).length).toBe(3);
});
});
});

0 comments on commit c3d78b9

Please sign in to comment.