parserDefaults = {
magic: {
PAGENAME: mw.config.get( 'wgPageName' ),
- PAGENAMEE: mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ),
- SITENAME: mw.config.get( 'wgSiteName' )
+ PAGENAMEE: mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) )
},
// Whitelist for allowed HTML elements in wikitext.
// Self-closing tags are not currently supported.
function appendWithoutParsing( $parent, children ) {
var i, len;
- if ( !$.isArray( children ) ) {
+ if ( !Array.isArray( children ) ) {
children = [ children ];
}
// eslint-disable-next-line new-cap
parser = new mw.jqueryMsg.parser( options ),
key = args[ 0 ],
- argsArray = $.isArray( args[ 1 ] ) ? args[ 1 ] : slice.call( args, 1 );
+ argsArray = Array.isArray( args[ 1 ] ) ? args[ 1 ] : slice.call( args, 1 );
try {
return parser.parse( key, argsArray );
} catch ( e ) {
* parsers, pass the relevant options to mw.jqueryMsg.parser.
*
* @private
- * @param {Object} data
+ * @param {Object} data New data to extend parser defaults with
+ * @param {boolean} [deep=false] Whether the extend is done recursively (deep)
*/
- mw.jqueryMsg.setParserDefaults = function ( data ) {
- $.extend( parserDefaults, data );
+ mw.jqueryMsg.setParserDefaults = function ( data, deep ) {
+ if ( deep ) {
+ $.extend( true, parserDefaults, data );
+ } else {
+ $.extend( parserDefaults, data );
+ }
};
/**
// recursive functions seem not to work in all browsers then. (Tested IE6-7, Opera, Safari, FF)
// This may be because, to save code, memoization was removed
+ /* eslint-disable no-useless-escape */
regularLiteral = makeRegexParser( /^[^{}\[\]$<\\]/ );
regularLiteralWithoutBar = makeRegexParser( /^[^{}\[\]$\\|]/ );
regularLiteralWithoutSpace = makeRegexParser( /^[^{}\[\]$\s]/ );
regularLiteralWithSquareBrackets = makeRegexParser( /^[^{}$\\]/ );
+ /* eslint-enable no-useless-escape */
backslash = makeStringParser( '\\' );
doubleQuote = makeStringParser( '"' );
templateName = transform(
// see $wgLegalTitleChars
// not allowing : due to the need to catch "PLURAL:$1"
- makeRegexParser( /^[ !"$&'()*,.\/0-9;=?@A-Z\^_`a-z~\x80-\xFF+\-]+/ ),
+ makeRegexParser( /^[ !"$&'()*,./0-9;=?@A-Z^_`a-z~\x80-\xFF+-]+/ ),
function ( result ) { return result.toString(); }
);
function templateParam() {
$el.attr( {
role: 'button',
tabindex: 0
- } )
- .on( 'click keypress', function ( e ) {
+ } ).on( 'click keypress', function ( e ) {
if (
e.type === 'click' ||
e.type === 'keypress' && e.which === 13
// Replace the default message parser with jqueryMsg
oldParser = mw.Message.prototype.parser;
mw.Message.prototype.parser = function () {
- if ( this.format === 'plain' || !/\{\{|[\[<>&]/.test( this.map.get( this.key ) ) ) {
+ if ( this.format === 'plain' || !/\{\{|[<>[&]/.test( this.map.get( this.key ) ) ) {
// Fall back to mw.msg's simple parser
return oldParser.apply( this );
}