jenkins-bot has submitted this change and it was merged.
Change subject: mediawiki.js: Move mw.format definition to where it's exposed
......................................................................
mediawiki.js: Move mw.format definition to where it's exposed
No need for it to be a local and public method at the same time.
The Message#parser can just use the public one.
Change-Id: I57e040cda6da57cda447ea83f5b9b6b28b538158
---
M resources/src/mediawiki/mediawiki.js
1 file changed, 10 insertions(+), 13 deletions(-)
Approvals:
Fomafix: Looks good to me, but someone else must approve
Jforrester: Looks good to me, approved
jenkins-bot: Verified
diff --git a/resources/src/mediawiki/mediawiki.js
b/resources/src/mediawiki/mediawiki.js
index 1763c8e..ff7012f 100644
--- a/resources/src/mediawiki/mediawiki.js
+++ b/resources/src/mediawiki/mediawiki.js
@@ -43,16 +43,6 @@
}
}
- // String format helper. Replaces $1, $2 .. $N placeholders with
positional
- // args. Used by Message.prototype.parser() and exported as mw.format().
- function format( formatString ) {
- var parameters = slice.call( arguments, 1 );
- return formatString.replace( /\$(\d+)/g, function ( str, match
) {
- var index = parseInt( match, 10 ) - 1;
- return parameters[index] !== undefined ?
parameters[index] : '$' + match;
- } );
- }
-
/* Object constructors */
/**
@@ -307,7 +297,7 @@
* This function will not be called for nonexistent messages.
*/
parser: function () {
- return format.apply( null, [ this.map.get( this.key )
].concat( this.parameters ) );
+ return mw.format.apply( null, [ this.map.get( this.key
) ].concat( this.parameters ) );
},
/**
@@ -444,13 +434,20 @@
/**
* Format a string. Replace $1, $2 ... $N with positional
arguments.
*
- * @method
+ * Used by Message#parser().
+ *
* @since 1.25
* @param {string} fmt Format string
* @param {Mixed...} parameters Substitutions for $N
placeholders.
* @return {string} Formatted string
*/
- format: format,
+ format: function ( formatString ) {
+ var parameters = slice.call( arguments, 1 );
+ return formatString.replace( /\$(\d+)/g, function (
str, match ) {
+ var index = parseInt( match, 10 ) - 1;
+ return parameters[index] !== undefined ?
parameters[index] : '$' + match;
+ } );
+ },
/**
* Track an analytic event.
--
To view, visit https://gerrit.wikimedia.org/r/184559
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I57e040cda6da57cda447ea83f5b9b6b28b538158
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Fomafix
Gerrit-Reviewer: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits