mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 08:35:56 +00:00 
			
		
		
		
	Refactor frontend unique id & comment (#34958)
* there is no bug of the "unique element id", but duplicate code, this PR just merges the duplicate "element id" logic and move the function from "fomaintic" to "dom" * improve comments * make "git commit graph" page update pagination links correctly
This commit is contained in:
		| @@ -1,9 +1,5 @@ | ||||
| import $ from 'jquery'; | ||||
| let ariaIdCounter = 0; | ||||
|  | ||||
| export function generateAriaId() { | ||||
|   return `_aria_auto_id_${ariaIdCounter++}`; | ||||
| } | ||||
| import {generateElemId} from '../../utils/dom.ts'; | ||||
|  | ||||
| export function linkLabelAndInput(label: Element, input: Element) { | ||||
|   const labelFor = label.getAttribute('for'); | ||||
| @@ -12,7 +8,7 @@ export function linkLabelAndInput(label: Element, input: Element) { | ||||
|   if (inputId && !labelFor) { // missing "for" | ||||
|     label.setAttribute('for', inputId); | ||||
|   } else if (!inputId && !labelFor) { // missing both "id" and "for" | ||||
|     const id = generateAriaId(); | ||||
|     const id = generateElemId('_aria_label_input_'); | ||||
|     input.setAttribute('id', id); | ||||
|     label.setAttribute('for', id); | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user