CoreFiles by mySites.guru
skip-link-focus-fix.js31 lines, 685 bytes, from wordpress-5.0.1.zip
Raw History Compare with 5.0
md5
93d421fd7576b0ca9c359ffe2fa16113
sha1
eacce35258f14fcd79bea2bc23f4140d25874322
sha256
14af47320898bd93f367026f7833c9956f14e24856976e4f9e10be31155cdcf2
/**
 * File skip-link-focus-fix.js.
 *
 * Helps with accessibility for keyboard only users.
 *
 * Learn more: https://git.io/vWdr2
 */
( function() {
	var isIe = /(trident|msie)/i.test( navigator.userAgent );

	if ( isIe && document.getElementById && window.addEventListener ) {
		window.addEventListener( 'hashchange', function() {
			var id = location.hash.substring( 1 ),
				element;

			if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
				return;
			}

			element = document.getElementById( id );

			if ( element ) {
				if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
					element.tabIndex = -1;
				}

				element.focus();
			}
		}, false );
	}
} )();

The same content is in 10 releases, WordPress 5.0-beta1 to 5.0.1. See them all, or every version of this file.