Skip to content

Commit

Permalink
fix: remove hardcoded aria-label attributes from links (#6492) (#6493)
Browse files Browse the repository at this point in the history
  • Loading branch information
sujoykd authored Sep 15, 2023
1 parent f7fcc7a commit 0dc7a28
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/cookie-consent/src/vaadin-cookie-consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ class CookieConsent extends ElementMixin(PolymerElement) {
name: this.cookieName,
},
position: this.position,
elements: {
messagelink: `<span id="cookieconsent:desc" class="cc-message">${this.message} <a tabindex="0" class="cc-link" href="${this.learnMoreLink}" target="_blank" rel="noopener noreferrer nofollow">${this.learnMore}</a></span>`,
dismiss: `<a tabindex="0" class="cc-btn cc-dismiss">${this.dismiss}</a>`,
},
});

const popup = this._getPopup();
Expand Down
34 changes: 33 additions & 1 deletion packages/cookie-consent/test/cookie-consent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('vaadin-cookie-consent', () => {
});
});

describe('cooke consent window', () => {
describe('cookie consent window', () => {
let consent, ccWindow;

beforeEach(async () => {
Expand Down Expand Up @@ -126,4 +126,36 @@ describe('vaadin-cookie-consent', () => {
expect(link.href).to.be.equal('https://example.com/');
});
});

describe('accessibility', () => {
let consent, ccWindow;

beforeEach(async () => {
consent = fixtureSync('<vaadin-cookie-consent></vaadin-cookie-consent>');

// Force cookie consent to appear.
consent._show();

// By default the cookie consent dialog has a 20 ms delay after it
// is initialized and before it starts the fade-in animation.
await aTimeout(50);

ccWindow = document.querySelector('.cc-window');
});

it('learn more link should not have role', () => {
const link = ccWindow.querySelector('.cc-link');
expect(link.hasAttribute('role')).to.be.false;
});

it('learn more link should not have aria-label', () => {
const link = ccWindow.querySelector('.cc-link');
expect(link.hasAttribute('aria-label')).to.be.false;
});

it('dismiss link should not have aria-label', () => {
const link = ccWindow.querySelector('.cc-dismiss');
expect(link.hasAttribute('aria-label')).to.be.false;
});
});
});

0 comments on commit 0dc7a28

Please sign in to comment.