CoreFiles by mySites.guru
skip-link-focus-fix.js31 lines, 684 bytes, from wordpress-4.7-beta2.zip
Raw History Compare with 4.7-beta1
md5
0b5a50859f564296d85b599c298880c7
sha1
171f94d741bad798582b8f03e3b03a7b96777139
sha256
7a5df905f2487b8afcc735d1f1fd4e6dde19e64f0c0279cedff181762b552185
/**
 * 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 2 releases, WordPress 4.7-beta2 to 4.7-beta3. See them all, or every version of this file.