CoreFiles by mySites.guru
skip-link-focus-fix.js35 lines, 823 bytes, from wordpress-6.0.13.zip
Raw History Compare with 6.0.12
md5
519ca723d9937a74a1d6f9024812db86
sha1
70c73efe38a3949f9416a450dc8fd9d19069ec0a
sha256
8f45a3eaee14c7254158b409f1b513a6cffc456298a042298ca385e044aeaaf2
/**
 * 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
 *
 * @since Twenty Twenty 1.0
 */
( 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 92 releases, WordPress 5.8-RC2 to 6.1-RC1. See them all, or every version of this file.