mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 10:22:23 +01:00
495b2d835f
This also reduces the number of browsers detected and patched with this fix. Most modern browsers have patched this common bug, where an anchor link does not move focus when clicked. Twenty Seventeen will only worry about older versions of Internet Explorer in this regard. Props afercia, sami.keijonen. See #38604. Built from https://develop.svn.wordpress.org/trunk@39135 git-svn-id: http://core.svn.wordpress.org/trunk@39075 1a063a9b-81f0-0310-95a4-ce76da25c4cd
32 lines
684 B
JavaScript
32 lines
684 B
JavaScript
/**
|
|
* 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 );
|
|
}
|
|
})();
|