1"use strict"; 2document.addEventListener('DOMContentLoaded', () => { 3 const focusableTags = ['a', 'button', 'input', 'textarea', 'select', 'summary']; 4 const isVisibleAndEnabled = (el) => { 5 if (el.hasAttribute('disabled')) 6 return false; 7 if (el.hasAttribute('hidden')) 8 return false; 9 if (el.getAttribute('aria-hidden') === 'true') 10 return false; 11 const style = window.getComputedStyle(el); 12 return style.display !== 'none' && style.visibility !== 'hidden'; 13 }; 14 const normalizeTabIndex = () => { 15 const schedule = (cb) => window.requestIdleCallback ? window.requestIdleCallback(cb, { timeout: 500 }) : setTimeout(cb, 100); 16 schedule(() => { 17 document.querySelectorAll('[tabindex]').forEach(el => { 18 const tabindex = el.getAttribute('tabindex'); 19 if (tabindex !== '0' && isVisibleAndEnabled(el)) { 20 el.setAttribute('tabindex', '0'); 21 } 22 }); 23 focusableTags.forEach(tag => { 24 document.querySelectorAll(tag).forEach(el => { 25 if (!el.hasAttribute('tabindex') && isVisibleAndEnabled(el)) { 26 el.setAttribute('tabindex', '0'); 27 } 28 }); 29 }); 30 }); 31 }; 32 const observer = new MutationObserver(() => normalizeTabIndex()); 33 normalizeTabIndex(); 34 observer.observe(document.body, { childList: true, subtree: true }); 35});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.