WordPress/wp-content/themes/twentynineteen/js/skip-link-focus-fix.js
desrosj a2845863e5 Twenty Nineteen: Fixes and improvements.
This commit brings over several changes that occurred upstream in the theme’s GitHub repository into core.

- Fix the gallery caption link color. https://github.com/WordPress/twentynineteen/pull/687
- Remove left padding from pullquote blocks. https://github.com/WordPress/twentynineteen/pull/690
- Print `skip-link-focus-fix` inline instead of enqueueing as blocking script. https://github
.com/WordPress/twentynineteen/pull/47
- Fix and improve some strings with placeholders. https://github.com/WordPress/twentynineteen/pull/217
- Fixes some minor code quality issues. https://github.com/WordPress/twentynineteen/pull/237
- Fix PHP Warning: Parameter must be an array or an object that implements Countable. https://github
.com/WordPress/twentynineteen/pull/661
- Add missing text domain and escaping to comment author text. https://github.com/WordPress/twentynineteen/pull/274
- Remove hyphens rule for cover image text. https://github.com/WordPress/twentynineteen/pull/691
- Fix left/right-aligned pullquote spacing. https://github.com/WordPress/twentynineteen/pull/695
- Improve `readme.txt` to follow the correct standards for themes. https://github.com/WordPress/twentynineteen/issues/689

Props kjellr, allancole, dimadin, westonruter, khleomix, grapplerulrich, iCaleb, desrosj.

Merges [44196], [44199], and [44201-44202] into trunk.

Fixes #45424.
Built from https://develop.svn.wordpress.org/trunk@44305


git-svn-id: http://core.svn.wordpress.org/trunk@44135 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-19 03:24:11 +00:00

34 lines
794 B
JavaScript

/**
* File skip-link-focus-fix.js.
*
* Helps with accessibility for keyboard only users.
*
* This is the source file for what is minified in the twentynineteen_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 );
}
} )();