CoreFiles by mySites.guru
skip-link-focus-fix.js33 lines, 792 bytes, from wordpress-5.4.21.zip
Raw History Compare with 5.4.20
md5
a2f6e833737b0c5f14c6955df7e070ca
sha1
da4dad2a0fbe4b4ad5f1ea5643750c995cf9cab6
sha256
088624b2edfb8d221e44b67ce862fce7b4d77cf2caca6c7da4d892b119b84805
/**
 * File skip-link-focus-fix.js.
 *
 * Helps with accessibility for keyboard only users.
 *
 * This is the source file for what is minified in the twentytwenty_skip_link_focus_fix() PHP function.
 *
 * 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 179 releases, WordPress 5.3-RC3 to 5.8-RC1. See them all, or every version of this file.