[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-content/themes/twentytwentyone/assets/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 twenty_twenty_one_skip_link_focus_fix() PHP function.
   7   *
   8   * Learn more: https://git.io/vWdr2
   9   *
  10   * @since Twenty Twenty-One 1.0
  11   */
  12  ( function() {
  13      var isIe = /(trident|msie)/i.test( navigator.userAgent );
  14  
  15      if ( isIe && document.getElementById && window.addEventListener ) {
  16          window.addEventListener( 'hashchange', function() {
  17              var id = location.hash.substring( 1 ),
  18                  element;
  19  
  20              if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
  21                  return;
  22              }
  23  
  24              element = document.getElementById( id );
  25  
  26              if ( element ) {
  27                  if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
  28                      element.tabIndex = -1;
  29                  }
  30  
  31                  element.focus();
  32              }
  33          }, false );
  34      }
  35  }() );


Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1