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;
}
Но чё-то мне кажется что как-то проще оно должно быть...