Skip to content

Commit

Permalink
fix(a11y): add notification span to shadow root in Swiper Element
Browse files Browse the repository at this point in the history
fixes #6634
  • Loading branch information
nolimits4web committed May 8, 2023
1 parent 446af7e commit aa83a03
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/modules/a11y/a11y.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ export default function A11y({ swiper, extendParams, on }) {
const init = () => {
const params = swiper.params.a11y;

swiper.el.append(liveRegion);
if (swiper.isElement) {
swiper.el.shadowEl.append(liveRegion);
} else {
swiper.el.append(liveRegion);
}

// Container
const containerEl = swiper.el;
Expand Down Expand Up @@ -314,7 +318,7 @@ export default function A11y({ swiper, extendParams, on }) {
swiper.el.addEventListener('pointerup', handlePointerUp, true);
};
function destroy() {
if (liveRegion && liveRegion.length > 0) liveRegion.remove();
if (liveRegion) liveRegion.remove();
let { nextEl, prevEl } = swiper.navigation ? swiper.navigation : {};
nextEl = makeElementsArray(nextEl);
prevEl = makeElementsArray(prevEl);
Expand Down Expand Up @@ -345,9 +349,6 @@ export default function A11y({ swiper, extendParams, on }) {
liveRegion = createElement('span', swiper.params.a11y.notificationClass);
liveRegion.setAttribute('aria-live', 'assertive');
liveRegion.setAttribute('aria-atomic', 'true');
if (swiper.isElement) {
liveRegion.setAttribute('slot', 'container-end');
}
});

on('afterInit', () => {
Expand Down

0 comments on commit aa83a03

Please sign in to comment.