CoreFiles by mySites.guru
skip-link-focus-fix.js33 lines, 794 bytes, from wordpress-5.4.21.zip
Raw History Compare with 5.4.20
md5
e681113d8d6f473bd1207f6bb11a22e4
sha1
87d126cf61ed88cd68fb1127cb4a649ddf07ebdc
sha256
39402d4eb7f6061935d605a5e60023e0d31a9563ec2437f9974942ad61b34239
/**
 * File skip-link-focus-fix.js.
 *
 * Helps with accessibility for keyboard only users.
 *
 * This is the source file for what is minified in the twentynineteen_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 328 releases, WordPress 5.0.2-RC1 to 5.9-RC3. See them all, or every version of this file.