CoreFiles by mySites.guru
skip-link-focus-fix.js35 lines, 832 bytes, from wordpress-6.2.13.zip
Raw History Compare with 6.2.12
md5
b8718680cac98b46c29d6d9fda5e3f93
sha1
2135073fac58f812345a720e25d2283c0822a5e8
sha256
caccc9bd52b385b1d3ed8664985cd5b98a51891f12c2f31fba4cf4673cf2bd8a
/**
 * 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
 *
 * @since Twenty Twenty-One 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 178 releases, WordPress 5.8-RC2 to 6.4-RC4. See them all, or every version of this file.