Skip to content

Commit

Permalink
Make screen readers announce changes in the slides carousel. (#5892)
Browse files Browse the repository at this point in the history
Fixes #5485
  • Loading branch information
cramforce authored Oct 28, 2016
1 parent 97c75fe commit 90c965d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions extensions/amp-carousel/0.1/slidescroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ export class AmpSlideScroll extends BaseSlides {

this.slidesContainer_ = this.win.document.createElement('div');
this.slidesContainer_.classList.add('-amp-slides-container');
// Let screen reader know that this is a live area and changes
// to it (such after pressing next) should be announced to the
// user.
this.slidesContainer_.setAttribute('aria-live', 'polite');

// Workaround - https://bugs.webkit.org/show_bug.cgi?id=158821
if (this.hasNativeSnapPoints_) {
Expand Down
2 changes: 2 additions & 0 deletions extensions/amp-carousel/0.1/test/test-slidescroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ describe('SlideScroll', () => {
expect(
ampSlideScroll.getElementsByClassName('amp-carousel-slide').length)
.to.equal(5);
expect(ampSlideScroll.querySelector('.-amp-slides-container')
.getAttribute('aria-live')).to.equal('polite');
const impl = ampSlideScroll.implementation_;
expect(impl.slideWrappers_[0].classList.contains(SHOW_CLASS))
.to.be.true;
Expand Down

0 comments on commit 90c965d

Please sign in to comment.