Issues (311)

js/skip-link-focus-fix.js (1 issue)

Languages
Labels
Severity
1
/**
2
 * File skip-link-focus-fix.js.
3
 *
4
 * Helps with accessibility for keyboard only users.
5
 *
6
 * Learn more: https://git.io/vWdr2
7
 */
8
( function() {
9
	var isIe = /(trident|msie)/i.test( navigator.userAgent );
0 ignored issues
show
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
10
11
	if ( isIe && document.getElementById && window.addEventListener ) {
12
		window.addEventListener( 'hashchange', function() {
13
			var id = location.hash.substring( 1 ),
14
				element;
15
16
			if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
17
				return;
18
			}
19
20
			element = document.getElementById( id );
21
22
			if ( element ) {
23
				if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
24
					element.tabIndex = -1;
25
				}
26
27
				element.focus();
28
			}
29
		}, false );
30
	}
31
} )();
32