Handle links with empty or no title attributes

The script depends on a title being present in title attribute. So
skip links without title attributes (which were getting empty
attributes due to the implementation of removeTooltips) and bail on
trying to open a preview for links without a title.

Bug: 67728
Change-Id: I4cc744bea10af34741681f11e03d77b3d53e3a3b
This commit is contained in:
Derk-Jan Hartman 2014-05-20 00:42:41 +02:00 committed by Yuvipanda
parent d60a70867c
commit 5025f2beee
2 changed files with 6 additions and 3 deletions

View file

@ -91,6 +91,7 @@
*/
mw.popups.removeTooltips = function ( $elements ) {
$elements
.filter( '[title]:not([title=""])' )
.on( 'mouseenter focus', function () {
$( this )
.data( 'title', $( this ).attr( 'title' ) )
@ -146,9 +147,7 @@
* @method selectPopupElements
*/
mw.popups.selectPopupElements = function () {
var notSelector = ':not(' + mw.popups.IGNORE_CLASSES.join(', ') + ')';
return mw.popups.$content.find( 'a' + notSelector + ':not([title=""])' );
return mw.popups.$content.find( 'a:not(' + mw.popups.IGNORE_CLASSES.join(', ') + ')' );
};
mw.hook( 'wikipage.content').add( function ( $content ) {

View file

@ -35,6 +35,10 @@
title = link.data( 'title' ),
deferred = $.Deferred();
if ( !title ) {
return deferred.reject().promise();
}
mw.popups.render.currentRequest = mw.popups.api.get( {
action: 'query',
prop: 'extracts|pageimages|revisions|info',