Skip to content

Commit 09dc3a9

Browse files
authored
refactor(tab): remove tabIndex set and unset for jsdom (testing-library#379)
1 parent a270040 commit 09dc3a9

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

src/tab.js

-9
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,7 @@ function tab({shift = false, focusTrap} = {}) {
103103
!continueToTab && previousElement ? previousElement : nextElement
104104

105105
if (continueToTab) {
106-
const hasTabIndex = nextElement.getAttribute('tabindex') !== null
107-
if (!hasTabIndex) {
108-
nextElement.setAttribute('tabindex', '0') // jsdom requires tabIndex=0 for an item to become 'document.activeElement'
109-
}
110-
111106
focus(nextElement)
112-
113-
if (!hasTabIndex) {
114-
nextElement.removeAttribute('tabindex') // leave no trace. :)
115-
}
116107
}
117108

118109
fireEvent.keyUp(keyUpTarget, {...tabKeyInit})

0 commit comments

Comments
 (0)