This repository has been archived by the owner on Dec 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Include skip link JS for IE. * Output minified script without enqueuing it Fixes #935
- Loading branch information
1 parent
9c86374
commit 41b4bf3
Showing
2 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* File skip-link-focus-fix.js. | ||
* | ||
* Helps with accessibility for keyboard only users. | ||
* | ||
* This is the source file for what is minified in the twentytwenty_skip_link_focus_fix() PHP function. | ||
* | ||
* 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 ); | ||
} | ||
}() ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters