CoreFiles by mySites.guru
skip-link-focus-fix.js31 lines, 683 bytes, from wordpress-5.2.21.zip
Raw History Compare with 5.2.20
md5
75abd4cd8807b312f9f7faeb77ee774b
sha1
e7b7a7ed06d0123ab8667a1d1eeb23de9f2bece7
sha256
ca424c0181141900220a19f998ffa7660380bc99ab99557ad458a083251f7034
/**
 * File skip-link-focus-fix.js.
 *
 * Helps with accessibility for keyboard only users.
 *
 * 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 383 releases, WordPress 4.7-beta4 to 5.5.25. See them all, or every version of this file.