[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-content/themes/twentynineteen/js/ -> skip-link-focus-fix.js (source)

   1  /**
   2   * File skip-link-focus-fix.js.
   3   *
   4   * Helps with accessibility for keyboard only users.
   5   *
   6   * This is the source file for what is minified in the twentynineteen_skip_link_focus_fix() PHP function.
   7   *
   8   * Learn more: https://git.io/vWdr2
   9   */
  10  ( function() {
  11      var isIe = /(trident|msie)/i.test( navigator.userAgent );
  12  
  13      if ( isIe && document.getElementById && window.addEventListener ) {
  14          window.addEventListener( 'hashchange', function() {
  15              var id = location.hash.substring( 1 ),
  16                  element;
  17  
  18              if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
  19                  return;
  20              }
  21  
  22              element = document.getElementById( id );
  23  
  24              if ( element ) {
  25                  if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
  26                      element.tabIndex = -1;
  27                  }
  28  
  29                  element.focus();
  30              }
  31          }, false );
  32      }
  33  } )();


Generated: Tue Sep 17 01:00:03 2019 Cross-referenced by PHPXref 0.7.1