Skip to content

Commit

Permalink
refactor(tab): remove tabIndex set and unset for jsdom (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanca committed Jun 22, 2020
1 parent a270040 commit 09dc3a9
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/tab.js
Expand Up @@ -103,16 +103,7 @@ function tab({shift = false, focusTrap} = {}) {
!continueToTab && previousElement ? previousElement : nextElement

if (continueToTab) {
const hasTabIndex = nextElement.getAttribute('tabindex') !== null
if (!hasTabIndex) {
nextElement.setAttribute('tabindex', '0') // jsdom requires tabIndex=0 for an item to become 'document.activeElement'
}

focus(nextElement)

if (!hasTabIndex) {
nextElement.removeAttribute('tabindex') // leave no trace. :)
}
}

fireEvent.keyUp(keyUpTarget, {...tabKeyInit})
Expand Down

0 comments on commit 09dc3a9

Please sign in to comment.