Показать сообщение отдельно
  #8 (permalink)  
Старый 09.10.2023, 00:20
Аватар для Aetae
Тлен
Отправить личное сообщение для Aetae Посмотреть профиль Найти все сообщения от Aetae
 
Регистрация: 02.01.2010
Сообщений: 6,595

ruslan_mart, твой костыль не учитывает тобой же приведённый вариант <a contentEditable>.
Как-то так оно должно выглядеть:
function getRealTabIndex(element: HTMLElement) {
  if(!element.hasAttribute('tabindex')) {
    // ContentEditable elements have a default tabindex of -1, although they behave like 0.
    // If this is the case, then treat the tabindex as 0
    if (element.isContentEditable) {
      return 0;
    }

    // Anchors without the "href" attribute have a default tab index of 0, although they behave like -1.
    // If this is the case, then treat the tabindex as -1
    if (element instanceof HTMLAnchorElement && !element.hasAttribute('href')) {
      return -1;
    }
  }
  
  return element.tabIndex;
}

Но чё-то мне кажется что как-то проще оно должно быть...
__________________
29375, 35
Ответить с цитированием