mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 19:06:18 +01:00 
			
		
		
		
	Enable Typescript noImplicitAny (#33322)
				
					
				
			Enable `noImplicitAny` and fix all issues. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -38,7 +38,7 @@ function ariaDropdownFn(this: any, ...args: Parameters<FomanticInitFunction>) { | ||||
| // the elements inside the dropdown menu item should not be focusable, the focus should always be on the dropdown primary element. | ||||
| function updateMenuItem(dropdown: HTMLElement, item: HTMLElement) { | ||||
|   if (!item.id) item.id = generateAriaId(); | ||||
|   item.setAttribute('role', dropdown[ariaPatchKey].listItemRole); | ||||
|   item.setAttribute('role', (dropdown as any)[ariaPatchKey].listItemRole); | ||||
|   item.setAttribute('tabindex', '-1'); | ||||
|   for (const el of item.querySelectorAll('a, input, button')) el.setAttribute('tabindex', '-1'); | ||||
| } | ||||
| @@ -61,7 +61,7 @@ function updateSelectionLabel(label: HTMLElement) { | ||||
|   } | ||||
| } | ||||
|  | ||||
| function processMenuItems($dropdown, dropdownCall) { | ||||
| function processMenuItems($dropdown: any, dropdownCall: any) { | ||||
|   const hideEmptyDividers = dropdownCall('setting', 'hideDividers') === 'empty'; | ||||
|   const itemsMenu = $dropdown[0].querySelector('.scrolling.menu') || $dropdown[0].querySelector('.menu'); | ||||
|   if (hideEmptyDividers) hideScopedEmptyDividers(itemsMenu); | ||||
| @@ -143,7 +143,7 @@ function attachStaticElements(dropdown: HTMLElement, focusable: HTMLElement, men | ||||
|   $(menu).find('> .item').each((_, item) => updateMenuItem(dropdown, item)); | ||||
|  | ||||
|   // this role could only be changed after its content is ready, otherwise some browsers+readers (like Chrome+AppleVoice) crash | ||||
|   menu.setAttribute('role', dropdown[ariaPatchKey].listPopupRole); | ||||
|   menu.setAttribute('role', (dropdown as any)[ariaPatchKey].listPopupRole); | ||||
|  | ||||
|   // prepare selection label items | ||||
|   for (const label of dropdown.querySelectorAll<HTMLElement>('.ui.label')) { | ||||
| @@ -151,8 +151,8 @@ function attachStaticElements(dropdown: HTMLElement, focusable: HTMLElement, men | ||||
|   } | ||||
|  | ||||
|   // make the primary element (focusable) aria-friendly | ||||
|   focusable.setAttribute('role', focusable.getAttribute('role') ?? dropdown[ariaPatchKey].focusableRole); | ||||
|   focusable.setAttribute('aria-haspopup', dropdown[ariaPatchKey].listPopupRole); | ||||
|   focusable.setAttribute('role', focusable.getAttribute('role') ?? (dropdown as any)[ariaPatchKey].focusableRole); | ||||
|   focusable.setAttribute('aria-haspopup', (dropdown as any)[ariaPatchKey].listPopupRole); | ||||
|   focusable.setAttribute('aria-controls', menu.id); | ||||
|   focusable.setAttribute('aria-expanded', 'false'); | ||||
|  | ||||
| @@ -164,7 +164,7 @@ function attachStaticElements(dropdown: HTMLElement, focusable: HTMLElement, men | ||||
| } | ||||
|  | ||||
| function attachInit(dropdown: HTMLElement) { | ||||
|   dropdown[ariaPatchKey] = {}; | ||||
|   (dropdown as any)[ariaPatchKey] = {}; | ||||
|   if (dropdown.classList.contains('custom')) return; | ||||
|  | ||||
|   // Dropdown has 2 different focusing behaviors | ||||
| @@ -204,9 +204,9 @@ function attachInit(dropdown: HTMLElement) { | ||||
|   // Since #19861 we have prepared the "combobox" solution, but didn't get enough time to put it into practice and test before. | ||||
|   const isComboBox = dropdown.querySelectorAll('input').length > 0; | ||||
|  | ||||
|   dropdown[ariaPatchKey].focusableRole = isComboBox ? 'combobox' : 'menu'; | ||||
|   dropdown[ariaPatchKey].listPopupRole = isComboBox ? 'listbox' : ''; | ||||
|   dropdown[ariaPatchKey].listItemRole = isComboBox ? 'option' : 'menuitem'; | ||||
|   (dropdown as any)[ariaPatchKey].focusableRole = isComboBox ? 'combobox' : 'menu'; | ||||
|   (dropdown as any)[ariaPatchKey].listPopupRole = isComboBox ? 'listbox' : ''; | ||||
|   (dropdown as any)[ariaPatchKey].listItemRole = isComboBox ? 'option' : 'menuitem'; | ||||
|  | ||||
|   attachDomEvents(dropdown, focusable, menu); | ||||
|   attachStaticElements(dropdown, focusable, menu); | ||||
| @@ -229,7 +229,7 @@ function attachDomEvents(dropdown: HTMLElement, focusable: HTMLElement, menu: HT | ||||
|     // if the popup is visible and has an active/selected item, use its id as aria-activedescendant | ||||
|     if (menuVisible) { | ||||
|       focusable.setAttribute('aria-activedescendant', active.id); | ||||
|     } else if (dropdown[ariaPatchKey].listPopupRole === 'menu') { | ||||
|     } else if ((dropdown as any)[ariaPatchKey].listPopupRole === 'menu') { | ||||
|       // for menu, when the popup is hidden, no need to keep the aria-activedescendant, and clear the active/selected item | ||||
|       focusable.removeAttribute('aria-activedescendant'); | ||||
|       active.classList.remove('active', 'selected'); | ||||
| @@ -253,7 +253,7 @@ function attachDomEvents(dropdown: HTMLElement, focusable: HTMLElement, menu: HT | ||||
|   // when the popup is hiding, it's better to have a small "delay", because there is a Fomantic UI animation | ||||
|   // without the delay for hiding, the UI will be somewhat laggy and sometimes may get stuck in the animation. | ||||
|   const deferredRefreshAriaActiveItem = (delay = 0) => { setTimeout(refreshAriaActiveItem, delay) }; | ||||
|   dropdown[ariaPatchKey].deferredRefreshAriaActiveItem = deferredRefreshAriaActiveItem; | ||||
|   (dropdown as any)[ariaPatchKey].deferredRefreshAriaActiveItem = deferredRefreshAriaActiveItem; | ||||
|   dropdown.addEventListener('keyup', (e) => { if (e.key.startsWith('Arrow')) deferredRefreshAriaActiveItem(); }); | ||||
|  | ||||
|   // if the dropdown has been opened by focus, do not trigger the next click event again. | ||||
| @@ -363,7 +363,7 @@ function onResponseKeepSelectedItem(dropdown: typeof $|HTMLElement, selectedValu | ||||
|   // then the dropdown only shows other items and will select another (wrong) one. | ||||
|   // It can't be easily fix by using setTimeout(patch, 0) in `onResponse` because the `onResponse` is called before another `setTimeout(..., timeLeft)` | ||||
|   // Fortunately, the "timeLeft" is controlled by "loadingDuration" which is always zero at the moment, so we can use `setTimeout(..., 10)` | ||||
|   const elDropdown = (dropdown instanceof HTMLElement) ? dropdown : dropdown[0]; | ||||
|   const elDropdown = (dropdown instanceof HTMLElement) ? dropdown : (dropdown as any)[0]; | ||||
|   setTimeout(() => { | ||||
|     queryElems(elDropdown, `.menu .item[data-value="${CSS.escape(selectedValue)}"].filtered`, (el) => el.classList.remove('filtered')); | ||||
|     $(elDropdown).dropdown('set selected', selectedValue ?? ''); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user