CoreFiles by mySites.guru
skip-link-focus-fix.js33 lines, 880 bytes, from wordpress-4.7-beta1.zip
Raw History Compare with 4.6-beta4
md5
381a9581291af74e622863b9ae1436bd
sha1
f35f2272e27f51dcfaa0a78f7595bce348b62b9c
sha256
c9104efada1e3f4b091183121a645b8298608c10a5b16bc3b1cbcb409b4f2777
/**
 * File skip-link-focus-fix.js.
 *
 * Helps with accessibility for keyboard only users.
 *
 * Learn more: https://git.io/vWdr2
 */
( function() {
	var isWebkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1,
	    isOpera  = navigator.userAgent.toLowerCase().indexOf( 'opera' )  > -1,
	    isIe     = navigator.userAgent.toLowerCase().indexOf( 'msie' )   > -1;

	if ( ( isWebkit || isOpera || 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 );
	}
})();

No other release has this exact content. See every version of this file.