Fixes in `admin-bar.js`:

- Silence errors when a node doesn't exist similarly to jQuery.
- Add "feature testing" and fallbacks for old browsers as this may run on the front-end.
- Improve inline docs.

Props dinhtungdu, azaozz.
Merges [46883] to the 5.3 branch.
Fixes #47069.


Built from https://develop.svn.wordpress.org/branches/5.3@46884


git-svn-id: http://core.svn.wordpress.org/branches/5.3@46684 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2019-12-11 20:23:05 +00:00
parent e4cf151207
commit 9e38fc8259
3 changed files with 199 additions and 141 deletions

View File

@ -4,45 +4,54 @@
/** /**
* Admin bar with Vanilla JS, no external dependencies. * Admin bar with Vanilla JS, no external dependencies.
* *
* @since 5.3.1
*
* @param {Object} document The document object. * @param {Object} document The document object.
* @param {Object} window The window object. * @param {Object} window The window object.
* @param {Object} navigator The navigator object. * @param {Object} navigator The navigator object.
* *
* @return {void} * @return {void}
*/ */
/* global hoverintent */
( function( document, window, navigator ) { ( function( document, window, navigator ) {
document.addEventListener( 'DOMContentLoaded', function() { document.addEventListener( 'DOMContentLoaded', function() {
var adminBar = document.getElementById( 'wpadminbar' ), var adminBar = document.getElementById( 'wpadminbar' ),
topMenuItems = adminBar.querySelectorAll( 'li.menupop' ), topMenuItems,
allMenuItems = adminBar.querySelectorAll( '.ab-item' ), allMenuItems,
adminBarLogout = document.getElementById( 'wp-admin-bar-logout' ), adminBarLogout,
adminBarSearchForm = document.getElementById( 'adminbarsearch' ), adminBarSearchForm,
shortlink = document.getElementById( 'wp-admin-bar-get-shortlink' ), shortlink,
skipLink = adminBar.querySelector( '.screen-reader-shortcut' ), skipLink,
mobileEvent = /Mobile\/.+Safari/.test( navigator.userAgent ) ? 'touchstart' : 'click', mobileEvent,
fontFaceRegex,
adminBarSearchInput, adminBarSearchInput,
i; i;
/** if ( ! adminBar || ! ( 'querySelectorAll' in adminBar ) ) {
* Remove nojs class after the DOM is loaded. return;
*/ }
adminBar.classList.remove( 'nojs' );
topMenuItems = adminBar.querySelectorAll( 'li.menupop' );
allMenuItems = adminBar.querySelectorAll( '.ab-item' );
adminBarLogout = document.getElementById( 'wp-admin-bar-logout' );
adminBarSearchForm = document.getElementById( 'adminbarsearch' );
shortlink = document.getElementById( 'wp-admin-bar-get-shortlink' );
skipLink = adminBar.querySelector( '.screen-reader-shortcut' );
mobileEvent = /Mobile\/.+Safari/.test( navigator.userAgent ) ? 'touchstart' : 'click';
fontFaceRegex = /Android (1.0|1.1|1.5|1.6|2.0|2.1)|Nokia|Opera Mini|w(eb)?OSBrowser|webOS|UCWEB|Windows Phone OS 7|XBLWP7|ZuneWP7|MSIE 7/;
// Remove nojs class after the DOM is loaded.
removeClass( adminBar, 'nojs' );
if ( 'ontouchstart' in window ) { if ( 'ontouchstart' in window ) {
/** // Remove hover class when the user touches outside the menu items.
* Remove hover class when the user touches outside the menu items.
*/
document.body.addEventListener( mobileEvent, function( e ) { document.body.addEventListener( mobileEvent, function( e ) {
if ( ! getClosest( e.target, 'li.menupop' ) ) { if ( ! getClosest( e.target, 'li.menupop' ) ) {
removeAllHoverClass( topMenuItems ); removeAllHoverClass( topMenuItems );
} }
} ); } );
/** // Add listener for menu items to toggle hover class by touches.
* Add listener for menu items to toggle hover class by touches. // Remove the callback later for better performance.
* Remove the callback later for better performance.
*/
adminBar.addEventListener( 'touchstart', function bindMobileEvents() { adminBar.addEventListener( 'touchstart', function bindMobileEvents() {
for ( var i = 0; i < topMenuItems.length; i++ ) { for ( var i = 0; i < topMenuItems.length; i++ ) {
topMenuItems[i].addEventListener( 'click', mobileHover.bind( null, topMenuItems ) ); topMenuItems[i].addEventListener( 'click', mobileHover.bind( null, topMenuItems ) );
@ -52,32 +61,24 @@
} ); } );
} }
/** // Scroll page to top when clicking on the admin bar.
* Scroll page to top when clicking on the admin bar.
*/
adminBar.addEventListener( 'click', scrollToTop ); adminBar.addEventListener( 'click', scrollToTop );
for ( i = 0; i < topMenuItems.length; i++ ) { for ( i = 0; i < topMenuItems.length; i++ ) {
/** // Adds or removes the hover class based on the hover intent.
* Adds or removes the hover class based on the hover intent. window.hoverintent(
*/
hoverintent(
topMenuItems[i], topMenuItems[i],
addHoverClass.bind( null, topMenuItems[i] ), addClass.bind( null, topMenuItems[i], 'hover' ),
removeHoverClass.bind( null, topMenuItems[i] ) removeClass.bind( null, topMenuItems[i], 'hover' )
).options( { ).options( {
timeout: 180 timeout: 180
} ); } );
/** // Toggle hover class if the enter key is pressed.
* Toggle hover class if the enter key is pressed.
*/
topMenuItems[i].addEventListener( 'keydown', toggleHoverIfEnter ); topMenuItems[i].addEventListener( 'keydown', toggleHoverIfEnter );
} }
/** // Remove hover class if the escape key is pressed.
* Remove hover class if the escape key is pressed.
*/
for ( i = 0; i < allMenuItems.length; i++ ) { for ( i = 0; i < allMenuItems.length; i++ ) {
allMenuItems[i].addEventListener( 'keydown', removeHoverIfEscape ); allMenuItems[i].addEventListener( 'keydown', removeHoverIfEscape );
} }
@ -85,131 +86,128 @@
if ( adminBarSearchForm ) { if ( adminBarSearchForm ) {
adminBarSearchInput = document.getElementById( 'adminbar-search' ); adminBarSearchInput = document.getElementById( 'adminbar-search' );
/** // Adds the adminbar-focused class on focus.
* Adds the adminbar-focused class on focus.
*/
adminBarSearchInput.addEventListener( 'focus', function() { adminBarSearchInput.addEventListener( 'focus', function() {
adminBarSearchForm.classList.add( 'adminbar-focused' ); addClass( adminBarSearchForm, 'adminbar-focused' );
} ); } );
/** // Removes the adminbar-focused class on blur.
* Removes the adminbar-focused class on blur.
*/
adminBarSearchInput.addEventListener( 'blur', function() { adminBarSearchInput.addEventListener( 'blur', function() {
adminBarSearchForm.classList.remove( 'adminbar-focused' ); removeClass( adminBarSearchForm, 'adminbar-focused' );
} ); } );
} }
/** if ( skipLink ) {
* Focus the target of skip link after pressing Enter. // Focus the target of skip link after pressing Enter.
*/
skipLink.addEventListener( 'keydown', focusTargetAfterEnter ); skipLink.addEventListener( 'keydown', focusTargetAfterEnter );
}
if ( shortlink ) { if ( shortlink ) {
shortlink.addEventListener( 'click', clickShortlink ); shortlink.addEventListener( 'click', clickShortlink );
} }
/** // Prevents the toolbar from covering up content when a hash is present in the URL.
* Prevents the toolbar from covering up content when a hash is present
* in the URL.
*/
if ( window.location.hash ) { if ( window.location.hash ) {
window.scrollBy( 0, -32 ); window.scrollBy( 0, -32 );
} }
/** // Add no-font-face class to body if needed.
* Add no-font-face class to body if needed. if (
*/ navigator.userAgent &&
if ( navigator.userAgent && document.body.className.indexOf( 'no-font-face' ) === -1 && fontFaceRegex.test( navigator.userAgent ) &&
/Android (1.0|1.1|1.5|1.6|2.0|2.1)|Nokia|Opera Mini|w(eb)?OSBrowser|webOS|UCWEB|Windows Phone OS 7|XBLWP7|ZuneWP7|MSIE 7/.test( navigator.userAgent ) ) { ! hasClass( document.body, 'no-font-face' )
document.body.className += ' no-font-face'; ) {
addClass( document.body, 'no-font-face' );
} }
/** // Clear sessionStorage on logging out.
* Clear sessionStorage on logging out. if ( adminBarLogout ) {
*/
adminBarLogout.addEventListener( 'click', emptySessionStorage ); adminBarLogout.addEventListener( 'click', emptySessionStorage );
}
} ); } );
/** /**
* Remove hover class for top level menu item when escape is pressed. * Remove hover class for top level menu item when escape is pressed.
* *
* @since 5.3.0 * @since 5.3.1
* *
* @param {Event} e The keydown event. * @param {Event} event The keydown event.
*/ */
function removeHoverIfEscape( e ) { function removeHoverIfEscape( event ) {
var wrapper; var wrapper;
if ( e.which != 27 ) { if ( event.which !== 27 ) {
return; return;
} }
wrapper = getClosest( e.target, '.menupop' ); wrapper = getClosest( event.target, '.menupop' );
if ( ! wrapper ) { if ( ! wrapper ) {
return; return;
} }
wrapper.querySelector( '.menupop > .ab-item' ).focus(); wrapper.querySelector( '.menupop > .ab-item' ).focus();
removeHoverClass( wrapper ); removeClass( wrapper, 'hover' );
} }
/** /**
* Toggle hover class for top level menu item when enter is pressed. * Toggle hover class for top level menu item when enter is pressed.
* *
* @since 5.3.0 * @since 5.3.1
* *
* @param {Event} e The keydown event. * @param {Event} event The keydown event.
*/ */
function toggleHoverIfEnter( e ) { function toggleHoverIfEnter( event ) {
var wrapper; var wrapper;
if ( e.which != 13 ) { if ( event.which !== 13 ) {
return; return;
} }
if ( !! getClosest( e.target, '.ab-sub-wrapper' ) ) { if ( !! getClosest( event.target, '.ab-sub-wrapper' ) ) {
return; return;
} }
wrapper = getClosest( e.target, '.menupop' ); wrapper = getClosest( event.target, '.menupop' );
if ( ! wrapper ) { if ( ! wrapper ) {
return; return;
} }
e.preventDefault(); event.preventDefault();
if ( hasHoverClass( wrapper ) ) {
removeHoverClass( wrapper ); if ( hasClass( wrapper, 'hover' ) ) {
removeClass( wrapper, 'hover' );
} else { } else {
addHoverClass( wrapper ); addClass( wrapper, 'hover' );
} }
} }
/** /**
* Focus the target of skip link after pressing Enter. * Focus the target of skip link after pressing Enter.
* *
* @since 5.3.0 * @since 5.3.1
* *
* @param {Event} e The keydown event. * @param {Event} event The keydown event.
*/ */
function focusTargetAfterEnter( e ) { function focusTargetAfterEnter( event ) {
var id, userAgent; var id, userAgent;
if ( 13 !== e.which ) { if ( event.which !== 13 ) {
return; return;
} }
id = e.target.getAttribute( 'href' ); id = event.target.getAttribute( 'href' );
userAgent = navigator.userAgent.toLowerCase(); userAgent = navigator.userAgent.toLowerCase();
if ( userAgent.indexOf( 'applewebkit' ) != -1 && id && id.charAt( 0 ) == '#' ) { if ( userAgent.indexOf( 'applewebkit' ) > -1 && id && id.charAt( 0 ) === '#' ) {
setTimeout( function() { setTimeout( function() {
var target = document.getElementById( id.replace( '#', '' ) ); var target = document.getElementById( id.replace( '#', '' ) );
if ( target ) {
target.setAttribute( 'tabIndex', '0' ); target.setAttribute( 'tabIndex', '0' );
target.focus(); target.focus();
}
}, 100 ); }, 100 );
} }
} }
@ -217,31 +215,31 @@
/** /**
* Toogle hover class for mobile devices. * Toogle hover class for mobile devices.
* *
* @since 5.3.0 * @since 5.3.1
* *
* @param {NodeList} topMenuItems All menu items. * @param {NodeList} topMenuItems All menu items.
* @param {Event} e The click event. * @param {Event} event The click event.
*/ */
function mobileHover( topMenuItems, e ) { function mobileHover( topMenuItems, event ) {
var wrapper; var wrapper;
if ( !! getClosest( e.target, '.ab-sub-wrapper' ) ) { if ( !! getClosest( event.target, '.ab-sub-wrapper' ) ) {
return; return;
} }
e.preventDefault(); event.preventDefault();
wrapper = getClosest( e.target, '.menupop' ); wrapper = getClosest( event.target, '.menupop' );
if ( ! wrapper ) { if ( ! wrapper ) {
return; return;
} }
if ( hasHoverClass( wrapper ) ) { if ( hasClass( wrapper, 'hover' ) ) {
removeHoverClass( wrapper ); removeClass( wrapper, 'hover' );
} else { } else {
removeAllHoverClass( topMenuItems ); removeAllHoverClass( topMenuItems );
addHoverClass( wrapper ); addClass( wrapper, 'hover' );
} }
} }
@ -249,27 +247,36 @@
* Handles the click on the Shortlink link in the adminbar. * Handles the click on the Shortlink link in the adminbar.
* *
* @since 3.1.0 * @since 3.1.0
* @since 5.3.0 Use querySelector to clean up the function. * @since 5.3.1 Use querySelector to clean up the function.
*
* @param {Event} e The click event.
* *
* @param {Event} event The click event.
* @return {boolean} Returns false to prevent default click behavior. * @return {boolean} Returns false to prevent default click behavior.
*/ */
function clickShortlink( e ) { function clickShortlink( event ) {
var wrapper = e.target.parentNode, var wrapper = event.target.parentNode,
input;
if ( wrapper ) {
input = wrapper.querySelector( '.shortlink-input' ); input = wrapper.querySelector( '.shortlink-input' );
// IE doesn't support preventDefault, and does support returnValue
if ( e.preventDefault ) {
e.preventDefault();
} }
e.returnValue = false;
wrapper.classList.add( 'selected' ); if ( ! input ) {
return;
}
// (Old) IE doesn't support preventDefault, and does support returnValue
if ( event.preventDefault ) {
event.preventDefault();
}
event.returnValue = false;
addClass( wrapper, 'selected' );
input.focus(); input.focus();
input.select(); input.select();
input.onblur = function() { input.onblur = function() {
wrapper.classList.remove( 'selected' ); removeClass( wrapper, 'selected' );
}; };
return false; return false;
@ -278,64 +285,111 @@
/** /**
* Clear sessionStorage on logging out. * Clear sessionStorage on logging out.
* *
* @since 5.3.0 * @since 5.3.1
*/ */
function emptySessionStorage() { function emptySessionStorage() {
if ( 'sessionStorage' in window ) { if ( 'sessionStorage' in window ) {
try { try {
for ( var key in sessionStorage ) { for ( var key in sessionStorage ) {
if ( key.indexOf( 'wp-autosave-' ) != -1 ) { if ( key.indexOf( 'wp-autosave-' ) > -1 ) {
sessionStorage.removeItem( key ); sessionStorage.removeItem( key );
} }
} }
} catch ( e ) {} } catch ( er ) {}
} }
} }
/** /**
* Check if menu item has hover class. * Check if element has class.
* *
* @since 5.3.0 * @since 5.3.1
* *
* @param {HTMLElement} item Menu item Element. * @param {HTMLElement} element The HTML element.
* @param {String} className The class name.
* @return {bool} Whether the element has the className.
*/ */
function hasHoverClass( item ) { function hasClass( element, className ) {
return item.classList.contains( 'hover' ); var classNames;
if ( ! element ) {
return false;
}
if ( element.classList && element.classList.contains ) {
return element.classList.contains( className );
} else if ( element.className ) {
classNames = element.className.split( ' ' );
return classNames.indexOf( className ) > -1;
}
return false;
} }
/** /**
* Add hover class for menu item. * Add class to an element.
* *
* @since 5.3.0 * @since 5.3.1
* *
* @param {HTMLElement} item Menu item Element. * @param {HTMLElement} element The HTML element.
* @param {String} className The class name.
*/ */
function addHoverClass( item ) { function addClass( element, className ) {
item.classList.add( 'hover' ); if ( ! element ) {
return;
}
if ( element.classList && element.classList.add ) {
element.classList.add( className );
} else if ( ! hasClass( element, className ) ) {
if ( element.className ) {
element.className += ' ';
}
element.className += className;
}
} }
/** /**
* Remove hover class for menu item. * Remove class from an element.
* *
* @since 5.3.0 * @since 5.3.1
* *
* @param {HTMLElement} item Menu item Element. * @param {HTMLElement} element The HTML element.
* @param {String} className The class name.
*/ */
function removeHoverClass( item ) { function removeClass( element, className ) {
item.classList.remove( 'hover' ); var testName,
classes;
if ( ! element || ! hasClass( element, className ) ) {
return;
}
if ( element.classList && element.classList.remove ) {
element.classList.remove( className );
} else {
testName = ' ' + className + ' ';
classes = ' ' + element.className + ' ';
while ( classes.indexOf( testName ) > -1 ) {
classes = classes.replace( testName, '' );
}
element.className = classes.replace( /^[\s]+|[\s]+$/g, '' );
}
} }
/** /**
* Remove hover class for all menu items. * Remove hover class for all menu items.
* *
* @since 5.3.0 * @since 5.3.1
* *
* @param {NodeList} topMenuItems All menu items. * @param {NodeList} topMenuItems All menu items.
*/ */
function removeAllHoverClass( topMenuItems ) { function removeAllHoverClass( topMenuItems ) {
if ( topMenuItems && topMenuItems.length ) {
for ( var i = 0; i < topMenuItems.length; i++ ) { for ( var i = 0; i < topMenuItems.length; i++ ) {
if ( hasHoverClass( topMenuItems[i] ) ) { removeClass( topMenuItems[i], 'hover' );
removeHoverClass( topMenuItems[i] );
} }
} }
} }
@ -345,7 +399,7 @@
* *
* @since 3.4.0 * @since 3.4.0
* *
* @param {Event} e The Click event. * @param {Event} event The Click event.
* *
* @return {void} * @return {void}
*/ */
@ -353,9 +407,8 @@
// Only scroll when clicking on the wpadminbar, not on menus or submenus. // Only scroll when clicking on the wpadminbar, not on menus or submenus.
if ( if (
event.target && event.target &&
event.target.id && event.target.id !== 'wpadminbar' &&
event.target.id != 'wpadminbar' && event.target.id !== 'wp-admin-bar-top-secondary'
event.target.id != 'wp-admin-bar-top-secondary'
) { ) {
return; return;
} }
@ -374,23 +427,26 @@
/** /**
* Get closest Element. * Get closest Element.
* *
* @since 5.3.0 * @since 5.3.1
* *
* @param {HTMLElement} el Element to get parent. * @param {HTMLElement} el Element to get parent.
* @param {string} selector CSS selector to match. * @param {string} selector CSS selector to match.
*/ */
function getClosest( el, selector ) { function getClosest( el, selector ) {
if ( ! Element.prototype.matches ) { if ( ! window.Element.prototype.matches ) {
Element.prototype.matches = // Polyfill from https://developer.mozilla.org/en-US/docs/Web/API/Element/matches.
Element.prototype.matchesSelector || window.Element.prototype.matches =
Element.prototype.mozMatchesSelector || window.Element.prototype.matchesSelector ||
Element.prototype.msMatchesSelector || window.Element.prototype.mozMatchesSelector ||
Element.prototype.oMatchesSelector || window.Element.prototype.msMatchesSelector ||
Element.prototype.webkitMatchesSelector || window.Element.prototype.oMatchesSelector ||
window.Element.prototype.webkitMatchesSelector ||
function( s ) { function( s ) {
var matches = ( this.document || this.ownerDocument ).querySelectorAll( s ), var matches = ( this.document || this.ownerDocument ).querySelectorAll( s ),
i = matches.length; i = matches.length;
while ( --i >= 0 && matches.item( i ) !== this ) { } while ( --i >= 0 && matches.item( i ) !== this ) { }
return i > -1; return i > -1;
}; };
} }
@ -401,6 +457,8 @@
return el; return el;
} }
} }
return null; return null;
} }
} )( document, window, navigator ); } )( document, window, navigator );

View File

@ -1 +1 @@
!function(u,d,m){function f(e){var t;27==e.which&&(t=S(e.target,".menupop"))&&(t.querySelector(".menupop > .ab-item").focus(),E(t))}function p(e){var t;13==e.which&&(S(e.target,".ab-sub-wrapper")||(t=S(e.target,".menupop"))&&(e.preventDefault(),r(t)?E(t):y(t)))}function h(e){var t;13===e.which&&(t=e.target.getAttribute("href"),-1!=m.userAgent.toLowerCase().indexOf("applewebkit")&&t&&"#"==t.charAt(0)&&setTimeout(function(){var e=u.getElementById(t.replace("#",""));e.setAttribute("tabIndex","0"),e.focus()},100))}function v(e,t){var n;S(t.target,".ab-sub-wrapper")||(t.preventDefault(),(n=S(t.target,".menupop"))&&(r(n)?E(n):(w(e),y(n))))}function g(e){var t=e.target.parentNode,n=t.querySelector(".shortlink-input");return e.preventDefault&&e.preventDefault(),e.returnValue=!1,t.classList.add("selected"),n.focus(),n.select(),!(n.onblur=function(){t.classList.remove("selected")})}function b(){if("sessionStorage"in d)try{for(var e in sessionStorage)-1!=e.indexOf("wp-autosave-")&&sessionStorage.removeItem(e)}catch(e){}}function r(e){return e.classList.contains("hover")}function y(e){e.classList.add("hover")}function E(e){e.classList.remove("hover")}function w(e){for(var t=0;t<e.length;t++)r(e[t])&&E(e[t])}function L(e){if(!e.target||!e.target.id||"wpadminbar"==e.target.id||"wp-admin-bar-top-secondary"==e.target.id)try{d.scrollTo({top:-32,left:0,behavior:"smooth"})}catch(e){d.scrollTo(0,-32)}}function S(e,t){for(Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),n=t.length;0<=--n&&t.item(n)!==this;);return-1<n});e&&e!==u;e=e.parentNode)if(e.matches(t))return e;return null}u.addEventListener("DOMContentLoaded",function(){var e,t,n=u.getElementById("wpadminbar"),r=n.querySelectorAll("li.menupop"),o=n.querySelectorAll(".ab-item"),a=u.getElementById("wp-admin-bar-logout"),i=u.getElementById("adminbarsearch"),s=u.getElementById("wp-admin-bar-get-shortlink"),c=n.querySelector(".screen-reader-shortcut"),l=/Mobile\/.+Safari/.test(m.userAgent)?"touchstart":"click";n.classList.remove("nojs"),"ontouchstart"in d&&(u.body.addEventListener(l,function(e){S(e.target,"li.menupop")||w(r)}),n.addEventListener("touchstart",function e(){for(var t=0;t<r.length;t++)r[t].addEventListener("click",v.bind(null,r));n.removeEventListener("touchstart",e)})),n.addEventListener("click",L);for(t=0;t<r.length;t++)hoverintent(r[t],y.bind(null,r[t]),E.bind(null,r[t])).options({timeout:180}),r[t].addEventListener("keydown",p);for(t=0;t<o.length;t++)o[t].addEventListener("keydown",f);i&&((e=u.getElementById("adminbar-search")).addEventListener("focus",function(){i.classList.add("adminbar-focused")}),e.addEventListener("blur",function(){i.classList.remove("adminbar-focused")})),c.addEventListener("keydown",h),s&&s.addEventListener("click",g),d.location.hash&&d.scrollBy(0,-32),m.userAgent&&-1===u.body.className.indexOf("no-font-face")&&/Android (1.0|1.1|1.5|1.6|2.0|2.1)|Nokia|Opera Mini|w(eb)?OSBrowser|webOS|UCWEB|Windows Phone OS 7|XBLWP7|ZuneWP7|MSIE 7/.test(m.userAgent)&&(u.body.className+=" no-font-face"),a.addEventListener("click",b)})}(document,window,navigator); !function(d,f,m){function p(e){var t;27===e.which&&(t=A(e.target,".menupop"))&&(t.querySelector(".menupop > .ab-item").focus(),w(t,"hover"))}function h(e){var t;13===e.which&&(A(e.target,".ab-sub-wrapper")||(t=A(e.target,".menupop"))&&(e.preventDefault(),E(t,"hover")?w(t,"hover"):L(t,"hover")))}function v(e){var t;13===e.which&&(t=e.target.getAttribute("href"),-1<m.userAgent.toLowerCase().indexOf("applewebkit")&&t&&"#"===t.charAt(0)&&setTimeout(function(){var e=d.getElementById(t.replace("#",""));e&&(e.setAttribute("tabIndex","0"),e.focus())},100))}function g(e,t){var n;A(t.target,".ab-sub-wrapper")||(t.preventDefault(),(n=A(t.target,".menupop"))&&(E(n,"hover")?w(n,"hover"):(S(e),L(n,"hover"))))}function b(e){var t,n=e.target.parentNode;if(n&&(t=n.querySelector(".shortlink-input")),t)return e.preventDefault&&e.preventDefault(),e.returnValue=!1,L(n,"selected"),t.focus(),t.select(),!(t.onblur=function(){w(n,"selected")})}function y(){if("sessionStorage"in f)try{for(var e in sessionStorage)-1<e.indexOf("wp-autosave-")&&sessionStorage.removeItem(e)}catch(e){}}function E(e,t){return!!e&&(e.classList&&e.classList.contains?e.classList.contains(t):!!e.className&&-1<e.className.split(" ").indexOf(t))}function L(e,t){e&&(e.classList&&e.classList.add?e.classList.add(t):E(e,t)||(e.className&&(e.className+=" "),e.className+=t))}function w(e,t){var n,r;if(e&&E(e,t))if(e.classList&&e.classList.remove)e.classList.remove(t);else{for(n=" "+t+" ",r=" "+e.className+" ";-1<r.indexOf(n);)r=r.replace(n,"");e.className=r.replace(/^[\s]+|[\s]+$/g,"")}}function S(e){if(e&&e.length)for(var t=0;t<e.length;t++)w(e[t],"hover")}function k(e){if(!e.target||"wpadminbar"===e.target.id||"wp-admin-bar-top-secondary"===e.target.id)try{f.scrollTo({top:-32,left:0,behavior:"smooth"})}catch(e){f.scrollTo(0,-32)}}function A(e,t){for(f.Element.prototype.matches||(f.Element.prototype.matches=f.Element.prototype.matchesSelector||f.Element.prototype.mozMatchesSelector||f.Element.prototype.msMatchesSelector||f.Element.prototype.oMatchesSelector||f.Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),n=t.length;0<=--n&&t.item(n)!==this;);return-1<n});e&&e!==d;e=e.parentNode)if(e.matches(t))return e;return null}d.addEventListener("DOMContentLoaded",function(){var n,e,t,r,o,a,s,i,c,l,u=d.getElementById("wpadminbar");if(u&&"querySelectorAll"in u){n=u.querySelectorAll("li.menupop"),e=u.querySelectorAll(".ab-item"),t=d.getElementById("wp-admin-bar-logout"),r=d.getElementById("adminbarsearch"),o=d.getElementById("wp-admin-bar-get-shortlink"),a=u.querySelector(".screen-reader-shortcut"),s=/Mobile\/.+Safari/.test(m.userAgent)?"touchstart":"click",i=/Android (1.0|1.1|1.5|1.6|2.0|2.1)|Nokia|Opera Mini|w(eb)?OSBrowser|webOS|UCWEB|Windows Phone OS 7|XBLWP7|ZuneWP7|MSIE 7/,w(u,"nojs"),"ontouchstart"in f&&(d.body.addEventListener(s,function(e){A(e.target,"li.menupop")||S(n)}),u.addEventListener("touchstart",function e(){for(var t=0;t<n.length;t++)n[t].addEventListener("click",g.bind(null,n));u.removeEventListener("touchstart",e)})),u.addEventListener("click",k);for(l=0;l<n.length;l++)f.hoverintent(n[l],L.bind(null,n[l],"hover"),w.bind(null,n[l],"hover")).options({timeout:180}),n[l].addEventListener("keydown",h);for(l=0;l<e.length;l++)e[l].addEventListener("keydown",p);r&&((c=d.getElementById("adminbar-search")).addEventListener("focus",function(){L(r,"adminbar-focused")}),c.addEventListener("blur",function(){w(r,"adminbar-focused")})),a&&a.addEventListener("keydown",v),o&&o.addEventListener("click",b),f.location.hash&&f.scrollBy(0,-32),m.userAgent&&i.test(m.userAgent)&&!E(d.body,"no-font-face")&&L(d.body,"no-font-face"),t&&t.addEventListener("click",y)}})}(document,window,navigator);

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.3.1-RC1-46877'; $wp_version = '5.3.1-RC1-46884';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.