Improve mw.popups.selectPopupElements

Use proven technology to create and compare URLs.
This will display popups also on anchored links again.

Change-Id: Ic010ca027017435f666782e709e641cf3bbb8767
This commit is contained in:
se4598 2015-02-24 18:19:43 +01:00 committed by Prateek Saxena
parent 64195b8ff7
commit 9974a75b50
2 changed files with 7 additions and 1 deletions

View file

@ -53,6 +53,7 @@ class PopupsHooks {
$moduleDependencies = array(
'mediawiki.api',
'mediawiki.jqueryMsg',
'mediawiki.Uri',
'moment',
'jquery.jStorage',
'jquery.client',

View file

@ -154,7 +154,12 @@
return mw.popups.$content
.find( 'a[href][title]:not(' + mw.popups.IGNORE_CLASSES.join(', ') + ')' )
.filter( function () {
return ( this.href.replace(/^https?:\/\//,'//') === ( mw.config.get( 'wgServer' ) + mw.util.getUrl( this.title ) ).replace(/^https?:\/\//,'//') );
var linkHref = new mw.Uri( this.href ),
expectedHref = new mw.Uri( mw.util.getUrl( this.title ) );
// don't compare fragment to display popups on anchored page links
linkHref.fragment = undefined;
return linkHref.toString() === expectedHref.toString();
} );
};