From 5025f2beee05b51b8ee06c9335968896a50029e9 Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Tue, 20 May 2014 00:42:41 +0200 Subject: [PATCH] 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 --- resources/ext.popups.core.js | 5 ++--- resources/ext.popups.renderer.article.js | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js index 9db8c8cfd..c44a0024d 100644 --- a/resources/ext.popups.core.js +++ b/resources/ext.popups.core.js @@ -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 ) { diff --git a/resources/ext.popups.renderer.article.js b/resources/ext.popups.renderer.article.js index 0348533d8..c0da5525d 100644 --- a/resources/ext.popups.renderer.article.js +++ b/resources/ext.popups.renderer.article.js @@ -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',