A11y live-region politeness fixed at polite in Swiper 8 ES-module builds
0 reputation · 30 Jan 2021, 09:10 UTC
0 reputation · 30 Jan 2021, 09:10 UTC
In Swiper 8 ES-module builds, the A11y module must be imported and registered explicitly through the modules array. Once active, it attaches ARIA labels to controls and renders a polite live region for slide-change announcements. The objective is to make autoplay-driven slide changes announce with assertive politeness so screen-reader users receive immediate notification.
The a11y options object exposes message text and a notification class, but no documented politeness setting. Swiper does not document a callback that isolates autoplay-driven transitions from user-initiated ones. Replacing the default notification element risks losing aria-live semantics if the substitute is not a live region.
polite to assertive without modifying Swiper source?aria-live semantics when replacing the default notification element in Swiper 8?35775 reputation · 30 Jan 2021, 12:10 UTC
No. In Swiper 8 ES-module builds, the A11y module creates its slide-change live region with aria-live="polite" and does not expose a politeness option in the a11y configuration object. There is no documented public API to switch that region to assertive, and no supported event that isolates autoplay-driven transitions from user-initiated ones.
Confirmed: you must import A11y and pass it in modules: [A11y]; otherwise no ARIA labels or live region are attached. The a11y options include message strings and a notification class, but not politeness. Swiper emits generic slideChange and autoplay lifecycle events, but no documented event or event argument distinguishes autoplay-driven transitions from user-initiated ones.
Likely: Swiper hard-codes polite when it builds the notification element. Because the module does not expose a setter or a per-cause event, any assertive behavior requires either mutating an internal property or changing source.
swiper.a11y?.liveRegion?.setAttribute('aria-live', 'assertive');This is version-sensitive and may be reset by Swiper during subsequent slide changes.aria-live and aria-atomic="true" in the same container. Do not substitute a plain <div> without ARIA live semantics.polite to assertive in the A11y module’s notify() logic. This is the only durable path, but it creates a maintenance burden on every Swiper upgrade.Setting every slide change to assertive interrupts screen-reader users immediately. Use it only when immediate announcement is required for all transitions, not just autoplay.
Does your Swiper build reset aria-live on the notification element inside notify() after a slide change? If the attribute reverts to polite, post-init mutation is not durable and a source-level change is the only reliable option. If it persists, the internal mutation workaround is viable for your version.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.