r112170 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112169‎ | r112170 | r112171 >
Date:00:39, 23 February 2012
Author:krinkle
Status:ok (Comments)
Tags:needs-js-test 
Comment:
[mw.util] bug fix and minor clean up
* Fixes bug 34603 (Patch by Rainer <Rainer@Rillke.eu>) 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).
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.util.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.util.js
@@ -2,7 +2,7 @@
33 * Implements mediaWiki.util library
44 */
55 ( function ( $, mw ) {
6 -"use strict";
 6+ "use strict";
77
88 // Local cache and alias
99 var util = {
@@ -121,19 +121,19 @@
122122 * @param str string String to be encoded
123123 */
124124 wikiUrlencode: function ( str ) {
125 - return this.rawurlencode( str )
 125+ return util.rawurlencode( str )
126126 .replace( /%20/g, '_' ).replace( /%3A/g, ':' ).replace( /%2F/g, '/' );
127127 },
128128
129129 /**
130130 * Get the link to a page name (relative to wgServer)
131131 *
132 - * @param str string Page name to get the link for.
133 - * @return string Location for a page with name of 'str' or boolean false on error.
 132+ * @param str String: Page name to get the link for.
 133+ * @return String: Location for a page with name of 'str' or boolean false on error.
134134 */
135135 wikiGetlink: function ( str ) {
136136 return mw.config.get( 'wgArticlePath' ).replace( '$1',
137 - this.wikiUrlencode( str || mw.config.get( 'wgPageName' ) ) );
 137+ util.wikiUrlencode( typeof str === 'string' ? str : mw.config.get( 'wgPageName' ) ) );
138138 },
139139
140140 /**
@@ -384,7 +384,7 @@
385385 $link.attr( 'title', tooltip );
386386 }
387387 if ( accesskey && tooltip ) {
388 - this.updateTooltipAccessKeys( $link );
 388+ util.updateTooltipAccessKeys( $link );
389389 }
390390
391391 // Where to put our node ?

Follow-up revisions

RevisionCommit summaryAuthorDate
r112632MFT r112170reedy20:41, 28 February 2012
r112644MFT r112169, r112170, r112172, r112173, r112179, r112184, r112290, r112313reedy21:13, 28 February 2012

Comments

#Comment by Krinkle (talk | contribs)   00:44, 23 February 2012

Also fixes bug 33347 :)

Status & tagging log