CoreFiles by mySites.guru
skip-link-focus-fix.js33 lines, 797 bytes, from wordpress-5.7.21.zip
Raw History Compare with 5.7.20
md5
37029f38347ce35de1d368b1d6a4e490
sha1
3537a11df10f7e9983fb9227a17fe3a2626e7100
sha256
f0a93e8650bf72015ac8c715f252218e245b5acf8c115f49594a98d5f48d8df2
/**
 * File skip-link-focus-fix.js.
 *
 * Helps with accessibility for keyboard only users.
 *
 * This is the source file for what is minified in the twenty_twenty_one_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 71 releases, WordPress 5.6-beta1 to 5.8-RC1. See them all, or every version of this file.