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