Last active
May 11, 2026 11:56
-
-
Save neodigm/bf64202df7ff854c910977eb1f2515a0 to your computer and use it in GitHub Desktop.
Flick Carousel ARIA-HIDDEN observer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FlickPatch { // Flick Carousel ARIA-HIDDEN observer | |
| constructor(_d, _sQ) { // πππππππππ | |
| this._d = _d; this._sQ = _sQ; | |
| this.aF = []; this.aObs = []; | |
| } | |
| init() { | |
| this.aF = Array.from( this._d.querySelectorAll( this._sQ )) | |
| if( this.aF.length ){ | |
| this.aObs = [] | |
| this.aF.forEach( ( eF )=>{ | |
| const oObs = new MutationObserver( flickPatch.removeAttr ); | |
| oObs.observe( eF, { attributes: true, childList: true, subtree: true } ); | |
| this.aObs.push( oObs ) | |
| }) | |
| } | |
| return this; | |
| } | |
| removeAttr( aObs ){ // | |
| if( aObs.length ){ | |
| aObs.forEach( ( elO )=>{ | |
| if( elO?.target ){ | |
| [ ... elO.target.querySelectorAll( "[aria-hidden='true']" )].forEach( ( eH )=>{ | |
| eH.removeAttribute("aria-hidden") | |
| }) | |
| } | |
| }) | |
| } | |
| } | |
| } | |
| //. Usage | |
| let flickPatch = {} | |
| document.addEventListener("DOMContentLoaded", ( ev )=>{ | |
| setTimeout( ()=>{ | |
| flickPatch = new FlickPatch( document, ".flickity-slider" ) | |
| flickPatch.init() | |
| }, 8e3 ) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was having some issues with this still triggering ADA compliance issues, ended up writing out a similar js assist script, not to hijack this thread at all but in case anyone is needing additional compliance assistance (tab index value toggling additionally) I threw mine up at https://github.com/luckyth13teen/Flickity_ada_assist .
Thanks for the initial jump off point Neodigm