From 903257064ef14dd19267b06b2a2421f126b7dcc5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 19 May 2016 19:22:06 +0200 Subject: [PATCH] Simplify code for updating tooltips with accesskey tips After 79e095fd, we can assume that if this code runs, then the fast querySelectorAll() is available, and therefore jQuery will use it rather than its polyfill. This completes the fix for T60255 started in ed85c136. Change-Id: I6b905ffb8ccf791d0edebfc15f2a4f1d1a57fbe1 --- resources/src/mediawiki/mediawiki.util.js | 18 ++---------------- resources/src/mediawiki/page/ready.js | 15 +-------------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/resources/src/mediawiki/mediawiki.util.js b/resources/src/mediawiki/mediawiki.util.js index 8dc8a61560..2ce54e47ca 100644 --- a/resources/src/mediawiki/mediawiki.util.js +++ b/resources/src/mediawiki/mediawiki.util.js @@ -541,9 +541,7 @@ * Add the appropriate prefix to the accesskey shown in the tooltip. * * If the `$nodes` parameter is given, only those nodes are updated; - * otherwise, depending on browser support, we update either all elements - * with accesskeys on the page or a bunch of elements which are likely to - * have them on core skins. + * otherwise we update all elements with accesskeys on the page. * * @method updateTooltipAccessKeys * @param {Array|jQuery} [$nodes] A jQuery object, or array of nodes to update. @@ -551,19 +549,7 @@ */ mw.log.deprecate( util, 'updateTooltipAccessKeys', function ( $nodes ) { if ( !$nodes ) { - if ( document.querySelectorAll ) { - // If we're running on a browser where we can do this efficiently, - // just find all elements that have accesskeys. We can't use jQuery's - // polyfill for the selector since looping over all elements on page - // load might be too slow. - $nodes = $( document.querySelectorAll( '[accesskey]' ) ); - } else { - // Otherwise go through some elements likely to have accesskeys rather - // than looping over all of them. Unfortunately this will not fully - // work for custom skins with different HTML structures. Input, label - // and button should be rare enough that no optimizations are needed. - $nodes = $( '#column-one a, #mw-head a, #mw-panel a, #p-logo a, input, label, button' ); - } + $nodes = $( '[accesskey]' ); } else if ( !( $nodes instanceof $ ) ) { $nodes = $( $nodes ); } diff --git a/resources/src/mediawiki/page/ready.js b/resources/src/mediawiki/page/ready.js index 2ad79eb88a..3b779d19af 100644 --- a/resources/src/mediawiki/page/ready.js +++ b/resources/src/mediawiki/page/ready.js @@ -44,20 +44,7 @@ } // Add accesskey hints to the tooltips - if ( document.querySelectorAll ) { - // If we're running on a browser where we can do this efficiently, - // just find all elements that have accesskeys. We can't use jQuery's - // polyfill for the selector since looping over all elements on page - // load might be too slow. - $nodes = $( document.querySelectorAll( '[accesskey]' ) ); - } else { - // Otherwise go through some elements likely to have accesskeys rather - // than looping over all of them. Unfortunately this will not fully - // work for custom skins with different HTML structures. Input, label - // and button should be rare enough that no optimizations are needed. - $nodes = $( '#column-one a, #mw-head a, #mw-panel a, #p-logo a, input, label, button' ); - } - $nodes.updateTooltipAccessKeys(); + $( '[accesskey]' ).updateTooltipAccessKeys(); // Infuse OOUI widgets, if any are present $oouiNodes = $( '[data-ooui]' ); -- 2.20.1