index.js
function tab( event ) {

  // Find all focusable elements in the dialog card
  var focusable   = dialogEl.querySelectorAll('input:not([type=hidden]), textarea, select, button'),
      last        = focusable[focusable.length - 1],
      focused     = document.activeElement

  // If focused on the last focusable element, tab to the first element.
  if ( focused == last ) {
    if ( event ){ event.preventDefault() }
    focusable[0].focus()
  }

  // Focus on the last element if the focused element is not a child of the dialog
  if ( !focused || !toolbox.childOf( focused, dialogEl ) ) {
    last.focus()
  }
}
function tab( event ) {

  // Find all focusable elements in the dialog card
  var focusable   = dialogEl.querySelectorAll('input:not([type=hidden]), textarea, select, button'),
      last        = focusable[focusable.length - 1],
      focused     = document.activeElement

  // If focused on the last focusable element, tab to the first element.
  if ( focused == last ) {
    if ( event ){ event.preventDefault() }
    focusable[0].focus()
  }

  // Focus on the last element if the focused element is not a child of the dialog
  if ( !focused || !toolbox.childOf( focused, dialogEl ) ) {
    last.focus()
  }
}
function tab ( event ) { // Find all focusable elements in the dialog card var focusable = dialogEl . querySelectorAll ( 'input:not([type=hidden]), textarea, select, button' ) , last = focusable [ focusable . length - 1 ] , focused = document . activeElement // If focused on the last focusable element, tab to the first element. if ( focused == last ) { if ( event ) { event . preventDefault ( ) } focusable [ 0 ] . focus ( ) } // Focus on the last element if the focused element is not a child of the dialog if ( ! focused || ! toolbox . childOf ( focused , dialogEl ) ) { last . focus ( ) } }
In a modal window, `tab` must cycle between elements in the modal.
In a modal window tab must cycle between elements in the modal .