From 06759528104220e5f3e24d61c61962e6799a3887 Mon Sep 17 00:00:00 2001 From: Krinkle Date: Thu, 23 Feb 2012 00:39:15 +0000 Subject: [PATCH] [mw.util] bug fix and minor clean up * Fixes bug 34603 (Patch by Rainer ) and other instances of the same bug -- Use 'util' instead of 'this' to allow re-usage of the method in a different context * Use ternary operator instead of the default operator in mw.util.wikiGetlink to check it for type instead of thruthy-ness (so that falsy-values such as '' work, and thruthy non-string values such as objects fail). --- resources/mediawiki/mediawiki.util.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/mediawiki/mediawiki.util.js b/resources/mediawiki/mediawiki.util.js index 4350737385..277b19457c 100644 --- a/resources/mediawiki/mediawiki.util.js +++ b/resources/mediawiki/mediawiki.util.js @@ -2,7 +2,7 @@ * Implements mediaWiki.util library */ ( function ( $, mw ) { -"use strict"; + "use strict"; // Local cache and alias var util = { @@ -121,19 +121,19 @@ * @param str string String to be encoded */ wikiUrlencode: function ( str ) { - return this.rawurlencode( str ) + return util.rawurlencode( str ) .replace( /%20/g, '_' ).replace( /%3A/g, ':' ).replace( /%2F/g, '/' ); }, /** * Get the link to a page name (relative to wgServer) * - * @param str string Page name to get the link for. - * @return string Location for a page with name of 'str' or boolean false on error. + * @param str String: Page name to get the link for. + * @return String: Location for a page with name of 'str' or boolean false on error. */ wikiGetlink: function ( str ) { return mw.config.get( 'wgArticlePath' ).replace( '$1', - this.wikiUrlencode( str || mw.config.get( 'wgPageName' ) ) ); + util.wikiUrlencode( typeof str === 'string' ? str : mw.config.get( 'wgPageName' ) ) ); }, /** @@ -384,7 +384,7 @@ $link.attr( 'title', tooltip ); } if ( accesskey && tooltip ) { - this.updateTooltipAccessKeys( $link ); + util.updateTooltipAccessKeys( $link ); } // Where to put our node ? -- 2.20.1