Skip to content

Commit

Permalink
feat(a11y): allow slideLabelMessage: null (#5783)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roni Laukkarinen authored Jun 10, 2022
1 parent 083a83f commit 78a8d90
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/modules/a11y/a11y.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,18 @@ export default function A11y({ swiper, extendParams, on }) {
? swiper.slides.filter((el) => !el.classList.contains(swiper.params.slideDuplicateClass))
.length
: swiper.slides.length;
swiper.slides.each((slideEl, index) => {
const $slideEl = $(slideEl);
const slideIndex = swiper.params.loop
? parseInt($slideEl.attr('data-swiper-slide-index'), 10)
: index;
const ariaLabelMessage = params.slideLabelMessage
.replace(/\{\{index\}\}/, slideIndex + 1)
.replace(/\{\{slidesLength\}\}/, slidesLength);
addElLabel($slideEl, ariaLabelMessage);
});
if (params.slideLabelMessage) {
swiper.slides.each((slideEl, index) => {
const $slideEl = $(slideEl);
const slideIndex = swiper.params.loop
? parseInt($slideEl.attr('data-swiper-slide-index'), 10)
: index;
const ariaLabelMessage = params.slideLabelMessage
.replace(/\{\{index\}\}/, slideIndex + 1)
.replace(/\{\{slidesLength\}\}/, slidesLength);
addElLabel($slideEl, ariaLabelMessage);
});
}
};

const init = () => {
Expand Down

0 comments on commit 78a8d90

Please sign in to comment.