code.gitea.io/gitea@v1.22.3/web_src/js/modules/fomantic/base.js (about) 1 let ariaIdCounter = 0; 2 3 export function generateAriaId() { 4 return `_aria_auto_id_${ariaIdCounter++}`; 5 } 6 7 export function linkLabelAndInput(label, input) { 8 const labelFor = label.getAttribute('for'); 9 const inputId = input.getAttribute('id'); 10 11 if (inputId && !labelFor) { // missing "for" 12 label.setAttribute('for', inputId); 13 } else if (!inputId && !labelFor) { // missing both "id" and "for" 14 const id = generateAriaId(); 15 input.setAttribute('id', id); 16 label.setAttribute('for', id); 17 } 18 }