<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[46884] Fixes in `admin-bar.js`:</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/46884">46884</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/46884","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>azaozz</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-12-11 20:21:08 +0000 (Wed, 11 Dec 2019)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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 <a href="https://core.trac.wordpress.org/changeset/46883">[46883]</a> to the 5.3 branch.
Fixes <a href="https://core.trac.wordpress.org/ticket/47069">#47069</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches53srcjs_enqueueslibadminbarjs">branches/5.3/src/js/_enqueues/lib/admin-bar.js</a></li>
</ul>
<h3>Property Changed</h3>
<ul>
<li><a href="#branches53">branches/5.3/</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx" style="display: block; padding: 0 10px">Index: branches/5.3
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- branches/5.3 2019-12-11 18:54:55 UTC (rev 46883)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ branches/5.3 2019-12-11 20:21:08 UTC (rev 46884)
</ins><a id="branches53"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: branches/5.3</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:mergeinfo</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> /branches/3.4:21757
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/4.9:43557,43622
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/5.0:43681-43682,43684-43688,43719-43720,43723,43726-43727,43729-43731,43734-43744,43747,43751-43754,43758,43760-43765,43767-43770,43772,43774-43781,43783,43785,43790-43806,43808-43821,43825,43828,43830-43834,43836-43843,43846-43863,43867-43889,43891-43894,43897-43905,43908-43909,43911-43929,43931-43942,43946-43947,43949-43956,43959-43964,43967-43969,43988,43994,44014,44017,44047,44183,44185,44187-44206,44208-44213,44231-44232,44235,44248,44284,44287-44288
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/trunk:46583,46605-46606,46613,46616,46656,46658,46665,46668,46676-46677,46700-46703,46705,46707,46709,46711,46713,46715,46719-46720,46722,46724,46738,46745-46748,46753,46756-46758,46761-46762,46765,46770,46772,46779,46782,46786,46788,46793,46795,46797,46809,46813,46815,46817,46822,46824,46832,46835,46837-46838,46840,46842,46844-46845,46849,46851-46852,46854,46856,46858,46860,46862,46864,46866,46868,46870,46872,46874
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/trunk:46583,46605-46606,46613,46616,46656,46658,46665,46668,46676-46677,46700-46703,46705,46707,46709,46711,46713,46715,46719-46720,46722,46724,46738,46745-46748,46753,46756-46758,46761-46762,46765,46770,46772,46779,46782,46786,46788,46793,46795,46797,46809,46813,46815,46817,46822,46824,46832,46835,46837-46838,46840,46842,46844-46845,46849,46851-46852,46854,46856,46858,46860,46862,46864,46866,46868,46870,46872,46874,46883
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="branches53srcjs_enqueueslibadminbarjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/5.3/src/js/_enqueues/lib/admin-bar.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/5.3/src/js/_enqueues/lib/admin-bar.js 2019-12-11 18:54:55 UTC (rev 46883)
+++ branches/5.3/src/js/_enqueues/lib/admin-bar.js 2019-12-11 20:21:08 UTC (rev 46884)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,6 +4,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Admin bar with Vanilla JS, no external dependencies.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param {Object} document The document object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {Object} window The window object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {Object} navigator The navigator object.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,29 +12,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return {void}
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* global hoverintent */
</del><span class="cx" style="display: block; padding: 0 10px"> ( function( document, window, navigator ) {
</span><span class="cx" style="display: block; padding: 0 10px"> document.addEventListener( 'DOMContentLoaded', function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var adminBar = document.getElementById( 'wpadminbar' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 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',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ topMenuItems,
+ allMenuItems,
+ adminBarLogout,
+ adminBarSearchForm,
+ shortlink,
+ skipLink,
+ mobileEvent,
+ fontFaceRegex,
</ins><span class="cx" style="display: block; padding: 0 10px"> adminBarSearchInput,
</span><span class="cx" style="display: block; padding: 0 10px"> i;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Remove nojs class after the DOM is loaded.
- */
- adminBar.classList.remove( 'nojs' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! adminBar || ! ( 'querySelectorAll' in adminBar ) ) {
+ return;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 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' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'ontouchstart' in window ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Remove hover class when the user touches outside the menu items.
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Remove hover class when the user touches outside the menu items.
</ins><span class="cx" style="display: block; padding: 0 10px"> document.body.addEventListener( mobileEvent, function( e ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! getClosest( e.target, 'li.menupop' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> removeAllHoverClass( topMenuItems );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -39,10 +50,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Add listener for menu items to toggle hover class by touches.
- * Remove the callback later for better performance.
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add listener for menu items to toggle hover class by touches.
+ // Remove the callback later for better performance.
</ins><span class="cx" style="display: block; padding: 0 10px"> adminBar.addEventListener( 'touchstart', function bindMobileEvents() {
</span><span class="cx" style="display: block; padding: 0 10px"> for ( var i = 0; i < topMenuItems.length; i++ ) {
</span><span class="cx" style="display: block; padding: 0 10px"> topMenuItems[i].addEventListener( 'click', mobileHover.bind( null, topMenuItems ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -52,32 +61,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Scroll page to top when clicking on the admin bar.
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Scroll page to top when clicking on the admin bar.
</ins><span class="cx" style="display: block; padding: 0 10px"> adminBar.addEventListener( 'click', scrollToTop );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> for ( i = 0; i < topMenuItems.length; i++ ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Adds or removes the hover class based on the hover intent.
- */
- hoverintent(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Adds or removes the hover class based on the hover intent.
+ window.hoverintent(
</ins><span class="cx" style="display: block; padding: 0 10px"> topMenuItems[i],
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- addHoverClass.bind( null, topMenuItems[i] ),
- removeHoverClass.bind( null, topMenuItems[i] )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ addClass.bind( null, topMenuItems[i], 'hover' ),
+ removeClass.bind( null, topMenuItems[i], 'hover' )
</ins><span class="cx" style="display: block; padding: 0 10px"> ).options( {
</span><span class="cx" style="display: block; padding: 0 10px"> timeout: 180
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Toggle hover class if the enter key is pressed.
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Toggle hover class if the enter key is pressed.
</ins><span class="cx" style="display: block; padding: 0 10px"> topMenuItems[i].addEventListener( 'keydown', toggleHoverIfEnter );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Remove hover class if the escape key is pressed.
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Remove hover class if the escape key is pressed.
</ins><span class="cx" style="display: block; padding: 0 10px"> for ( i = 0; i < allMenuItems.length; i++ ) {
</span><span class="cx" style="display: block; padding: 0 10px"> allMenuItems[i].addEventListener( 'keydown', removeHoverIfEscape );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -85,67 +86,61 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( adminBarSearchForm ) {
</span><span class="cx" style="display: block; padding: 0 10px"> adminBarSearchInput = document.getElementById( 'adminbar-search' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Adds the adminbar-focused class on focus.
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Adds the adminbar-focused class on focus.
</ins><span class="cx" style="display: block; padding: 0 10px"> adminBarSearchInput.addEventListener( 'focus', function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- adminBarSearchForm.classList.add( 'adminbar-focused' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ addClass( adminBarSearchForm, 'adminbar-focused' );
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Removes the adminbar-focused class on blur.
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Removes the adminbar-focused class on blur.
</ins><span class="cx" style="display: block; padding: 0 10px"> adminBarSearchInput.addEventListener( 'blur', function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- adminBarSearchForm.classList.remove( 'adminbar-focused' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ removeClass( adminBarSearchForm, 'adminbar-focused' );
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Focus the target of skip link after pressing Enter.
- */
- skipLink.addEventListener( 'keydown', focusTargetAfterEnter );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( skipLink ) {
+ // Focus the target of skip link after pressing Enter.
+ skipLink.addEventListener( 'keydown', focusTargetAfterEnter );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( shortlink ) {
</span><span class="cx" style="display: block; padding: 0 10px"> shortlink.addEventListener( 'click', clickShortlink );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Prevents the toolbar from covering up content when a hash is present
- * in the URL.
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Prevents the toolbar from covering up content when a hash is present in the URL.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( window.location.hash ) {
</span><span class="cx" style="display: block; padding: 0 10px"> window.scrollBy( 0, -32 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Add no-font-face class to body if needed.
- */
- if ( navigator.userAgent && document.body.className.indexOf( 'no-font-face' ) === -1 &&
- /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 ) ) {
- document.body.className += ' no-font-face';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add no-font-face class to body if needed.
+ if (
+ navigator.userAgent &&
+ fontFaceRegex.test( navigator.userAgent ) &&
+ ! hasClass( document.body, 'no-font-face' )
+ ) {
+ addClass( document.body, 'no-font-face' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Clear sessionStorage on logging out.
- */
- adminBarLogout.addEventListener( 'click', emptySessionStorage );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Clear sessionStorage on logging out.
+ if ( adminBarLogout ) {
+ adminBarLogout.addEventListener( 'click', emptySessionStorage );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Remove hover class for top level menu item when escape is pressed.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.3.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {Event} e The keydown event.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {Event} event The keydown event.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function removeHoverIfEscape( e ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function removeHoverIfEscape( event ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> var wrapper;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( e.which != 27 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( event.which !== 27 ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wrapper = getClosest( e.target, '.menupop' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wrapper = getClosest( event.target, '.menupop' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! wrapper ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -152,38 +147,39 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wrapper.querySelector( '.menupop > .ab-item' ).focus();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- removeHoverClass( wrapper );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ removeClass( wrapper, 'hover' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Toggle hover class for top level menu item when enter is pressed.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.3.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {Event} e The keydown event.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {Event} event The keydown event.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function toggleHoverIfEnter( e ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function toggleHoverIfEnter( event ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> var wrapper;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( e.which != 13 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( event.which !== 13 ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !! getClosest( e.target, '.ab-sub-wrapper' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( !! getClosest( event.target, '.ab-sub-wrapper' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wrapper = getClosest( e.target, '.menupop' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wrapper = getClosest( event.target, '.menupop' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! wrapper ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- e.preventDefault();
- if ( hasHoverClass( wrapper ) ) {
- removeHoverClass( wrapper );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ event.preventDefault();
+
+ if ( hasClass( wrapper, 'hover' ) ) {
+ removeClass( wrapper, 'hover' );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- addHoverClass( wrapper );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ addClass( wrapper, 'hover' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -190,26 +186,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Focus the target of skip link after pressing Enter.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.3.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {Event} e The keydown event.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {Event} event The keydown event.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function focusTargetAfterEnter( e ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function focusTargetAfterEnter( event ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> var id, userAgent;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 13 !== e.which ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( event.which !== 13 ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- id = e.target.getAttribute( 'href' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ id = event.target.getAttribute( 'href' );
</ins><span class="cx" style="display: block; padding: 0 10px"> userAgent = navigator.userAgent.toLowerCase();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( userAgent.indexOf( 'applewebkit' ) != -1 && id && id.charAt( 0 ) == '#' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( userAgent.indexOf( 'applewebkit' ) > -1 && id && id.charAt( 0 ) === '#' ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> setTimeout( function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var target = document.getElementById( id.replace( '#', '' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- target.setAttribute( 'tabIndex', '0' );
- target.focus();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( target ) {
+ target.setAttribute( 'tabIndex', '0' );
+ target.focus();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }, 100 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -217,31 +215,31 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Toogle hover class for mobile devices.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.3.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {NodeList} topMenuItems All menu items.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {Event} e The click event.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {Event} event The click event.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function mobileHover( topMenuItems, e ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function mobileHover( topMenuItems, event ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> var wrapper;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !! getClosest( e.target, '.ab-sub-wrapper' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( !! getClosest( event.target, '.ab-sub-wrapper' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- e.preventDefault();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ event.preventDefault();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wrapper = getClosest( e.target, '.menupop' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wrapper = getClosest( event.target, '.menupop' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! wrapper ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( hasHoverClass( wrapper ) ) {
- removeHoverClass( wrapper );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( hasClass( wrapper, 'hover' ) ) {
+ removeClass( wrapper, 'hover' );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> removeAllHoverClass( topMenuItems );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- addHoverClass( wrapper );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ addClass( wrapper, 'hover' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -249,27 +247,36 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Handles the click on the Shortlink link in the adminbar.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.1.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.3.0 Use querySelector to clean up the function.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1 Use querySelector to clean up the function.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {Event} e The click event.
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {Event} event The click event.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return {boolean} Returns false to prevent default click behavior.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function clickShortlink( e ) {
- var wrapper = e.target.parentNode,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function clickShortlink( event ) {
+ var wrapper = event.target.parentNode,
+ input;
+
+ if ( wrapper ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> input = wrapper.querySelector( '.shortlink-input' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // IE doesn't support preventDefault, and does support returnValue
- if ( e.preventDefault ) {
- e.preventDefault();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! input ) {
+ return;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- e.returnValue = false;
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wrapper.classList.add( 'selected' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // (Old) IE doesn't support preventDefault, and does support returnValue
+ if ( event.preventDefault ) {
+ event.preventDefault();
+ }
+
+ event.returnValue = false;
+
+ addClass( wrapper, 'selected' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> input.focus();
</span><span class="cx" style="display: block; padding: 0 10px"> input.select();
</span><span class="cx" style="display: block; padding: 0 10px"> input.onblur = function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wrapper.classList.remove( 'selected' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ removeClass( wrapper, 'selected' );
</ins><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -278,64 +285,111 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Clear sessionStorage on logging out.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.3.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function emptySessionStorage() {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'sessionStorage' in window ) {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="cx" style="display: block; padding: 0 10px"> for ( var key in sessionStorage ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( key.indexOf( 'wp-autosave-' ) != -1 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( key.indexOf( 'wp-autosave-' ) > -1 ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> sessionStorage.removeItem( key );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } catch ( e ) {}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } catch ( er ) {}
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Check if menu item has hover class.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Check if element has class.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.3.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {HTMLElement} item Menu item Element.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {HTMLElement} element The HTML element.
+ * @param {String} className The class name.
+ * @return {bool} Whether the element has the className.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function hasHoverClass( item ) {
- return item.classList.contains( 'hover' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function hasClass( element, className ) {
+ 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;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Add hover class for menu item.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Add class to an element.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.3.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {HTMLElement} item Menu item Element.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {HTMLElement} element The HTML element.
+ * @param {String} className The class name.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function addHoverClass( item ) {
- item.classList.add( 'hover' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function addClass( element, className ) {
+ 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;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Remove hover class for menu item.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Remove class from an element.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.3.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {HTMLElement} item Menu item Element.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {HTMLElement} element The HTML element.
+ * @param {String} className The class name.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function removeHoverClass( item ) {
- item.classList.remove( 'hover' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function removeClass( element, className ) {
+ 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, '' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Remove hover class for all menu items.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.3.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {NodeList} topMenuItems All menu items.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function removeAllHoverClass( topMenuItems ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- for ( var i = 0; i < topMenuItems.length; i++ ) {
- if ( hasHoverClass( topMenuItems[i] ) ) {
- removeHoverClass( topMenuItems[i] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( topMenuItems && topMenuItems.length ) {
+ for ( var i = 0; i < topMenuItems.length; i++ ) {
+ removeClass( topMenuItems[i], 'hover' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -345,7 +399,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.4.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {Event} e The Click event.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {Event} event The Click event.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return {void}
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -353,9 +407,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Only scroll when clicking on the wpadminbar, not on menus or submenus.
</span><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> event.target &&
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- event.target.id &&
- event.target.id != 'wpadminbar' &&
- event.target.id != 'wp-admin-bar-top-secondary'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ event.target.id !== 'wpadminbar' &&
+ event.target.id !== 'wp-admin-bar-top-secondary'
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -374,23 +427,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Get closest Element.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.3.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.3.1
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {HTMLElement} el Element to get parent.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {string} selector CSS selector to match.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function getClosest( el, selector ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! Element.prototype.matches ) {
- Element.prototype.matches =
- Element.prototype.matchesSelector ||
- Element.prototype.mozMatchesSelector ||
- Element.prototype.msMatchesSelector ||
- Element.prototype.oMatchesSelector ||
- Element.prototype.webkitMatchesSelector ||
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! window.Element.prototype.matches ) {
+ // Polyfill from https://developer.mozilla.org/en-US/docs/Web/API/Element/matches.
+ window.Element.prototype.matches =
+ window.Element.prototype.matchesSelector ||
+ window.Element.prototype.mozMatchesSelector ||
+ window.Element.prototype.msMatchesSelector ||
+ window.Element.prototype.oMatchesSelector ||
+ window.Element.prototype.webkitMatchesSelector ||
</ins><span class="cx" style="display: block; padding: 0 10px"> function( s ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var matches = ( this.document || this.ownerDocument ).querySelectorAll( s ),
</span><span class="cx" style="display: block; padding: 0 10px"> i = matches.length;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> while ( --i >= 0 && matches.item( i ) !== this ) { }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return i > -1;
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -401,6 +457,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return el;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return null;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> } )( document, window, navigator );
</span></span></pre>
</div>
</div>
</body>
</html>