mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-18 18:20:51 +00:00
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:
parent
d60a70867c
commit
5025f2beee
|
@ -91,6 +91,7 @@
|
||||||
*/
|
*/
|
||||||
mw.popups.removeTooltips = function ( $elements ) {
|
mw.popups.removeTooltips = function ( $elements ) {
|
||||||
$elements
|
$elements
|
||||||
|
.filter( '[title]:not([title=""])' )
|
||||||
.on( 'mouseenter focus', function () {
|
.on( 'mouseenter focus', function () {
|
||||||
$( this )
|
$( this )
|
||||||
.data( 'title', $( this ).attr( 'title' ) )
|
.data( 'title', $( this ).attr( 'title' ) )
|
||||||
|
@ -146,9 +147,7 @@
|
||||||
* @method selectPopupElements
|
* @method selectPopupElements
|
||||||
*/
|
*/
|
||||||
mw.popups.selectPopupElements = function () {
|
mw.popups.selectPopupElements = function () {
|
||||||
var notSelector = ':not(' + mw.popups.IGNORE_CLASSES.join(', ') + ')';
|
return mw.popups.$content.find( 'a:not(' + mw.popups.IGNORE_CLASSES.join(', ') + ')' );
|
||||||
|
|
||||||
return mw.popups.$content.find( 'a' + notSelector + ':not([title=""])' );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mw.hook( 'wikipage.content').add( function ( $content ) {
|
mw.hook( 'wikipage.content').add( function ( $content ) {
|
||||||
|
|
|
@ -35,6 +35,10 @@
|
||||||
title = link.data( 'title' ),
|
title = link.data( 'title' ),
|
||||||
deferred = $.Deferred();
|
deferred = $.Deferred();
|
||||||
|
|
||||||
|
if ( !title ) {
|
||||||
|
return deferred.reject().promise();
|
||||||
|
}
|
||||||
|
|
||||||
mw.popups.render.currentRequest = mw.popups.api.get( {
|
mw.popups.render.currentRequest = mw.popups.api.get( {
|
||||||
action: 'query',
|
action: 'query',
|
||||||
prop: 'extracts|pageimages|revisions|info',
|
prop: 'extracts|pageimages|revisions|info',
|
||||||
|
|
Loading…
Reference in a new issue