@@ -17,6 +17,11 @@ if (document.readyState === "interactive" || document.readyState === "complete"
1717 * Fixes accessibility violation: "Provide a mechanism for skipping past repetitive content"
1818 */
1919function applySkipLinks ( ) {
20+ document . querySelectorAll ( '#content' ) . forEach ( function ( contentDiv ) {
21+ contentDiv . setAttribute ( 'role' , 'main' ) ;
22+ contentDiv . setAttribute ( 'tabindex' , '-1' ) ;
23+ } ) ;
24+
2025 function insertSkipLink ( element ) {
2126 if ( element . querySelectorAll ( ".skip-to-content" ) . length > 0 ) { return }
2227
@@ -111,49 +116,9 @@ window.addEventListener('navigationLoaded', ensureNavButtonInteractable);
111116 * Fixes accessibility violation: "Ensure pages reflow without requiring two-dimensional scrolling without loss of content or functionality"
112117 */
113118function ensureContentReflow ( ) {
114- const MIN_WINDOW_SIZE = 550
115-
116- // Function to insert 'toggle content' button
117- function insertToggleContentButton ( element ) {
118- if ( element . parentNode . querySelectorAll ( ".aws-toggle-content-btn" ) . length > 0 ) { return }
119-
120- const initiallyVisible = window . innerWidth >= MIN_WINDOW_SIZE
121-
122- const toggleContent = document . createElement ( 'button' ) ;
123- toggleContent . className = 'aws-toggle-content-btn' ;
124- toggleContent . textContent = initiallyVisible ? '▼' : '▶'
125- toggleContent . setAttribute ( 'aria-expanded' , initiallyVisible . toString ( ) ) ;
126- toggleContent . setAttribute ( 'aria-label' , 'Toggle code block for' + element . getAttribute ( "data-togglable" ) ) ;
127- toggleContent . setAttribute ( 'aria-controls' , element . id ) ;
128-
129- // Set initial visibility based on window size
130- element . style . display = initiallyVisible ? 'block' : 'none'
131-
132- // Toggle visibility onclick
133- toggleContent . onclick = function ( ) {
134- const isExpanded = toggleContent . getAttribute ( 'aria-expanded' ) === 'true' ;
135- toggleContent . setAttribute ( 'aria-expanded' , ( ! isExpanded ) . toString ( ) ) ;
136- element . style . display = isExpanded ? 'none' : 'block'
137- toggleContent . textContent = isExpanded ? '▶' : '▼'
138- } ;
139-
140- element . parentNode . insertBefore ( toggleContent , element ) ;
141- }
142-
143- document . querySelectorAll ( '.content[data-togglable]' ) . forEach ( insertToggleContentButton ) ;
144-
145- // Update content visibility on resize
146- window . addEventListener ( 'resize' , function ( ) {
147- document . querySelectorAll ( '.content[data-togglable]' ) . forEach ( function ( element ) {
148- const toggleContent = element . previousSibling ;
149- if ( window . innerWidth < MIN_WINDOW_SIZE ) {
150- element . style . display = 'none' ;
151- toggleContent . setAttribute ( 'aria-expanded' , 'false' ) ;
152- } else {
153- element . style . display = 'block' ;
154- toggleContent . setAttribute ( 'aria-expanded' , 'true' ) ;
155- }
156- } ) ;
119+ // Ensure `content` sections are reflowable
120+ document . querySelectorAll ( '.content[data-togglable]' ) . forEach ( function ( content ) {
121+ content . style . display = 'block'
157122 } ) ;
158123}
159- window . addEventListener ( 'navigationLoaded' , ensureContentReflow ) ;
124+ window . addEventListener ( 'navigationLoaded' , ensureContentReflow ) ;
0 commit comments