MediaWiki:Gadget-morebits.js: Difference between revisions

Content deleted Content added
Repo at 63ed011: Drop = and }} for final parameter; tests for splitWeightByKeys; A few missing morebits.string tests
Repo at 8215b50: Note defaults for errorformat, uselang, and json's formatversion; Update deprecation notices; Add a few quick tests for Morebits.unbinder
Line 1,131:
RegExp.escape = function(text, space_fix) {
if (space_fix) {
console.warnerror('NOTE: RegExp.escape from Morebits was deprecated September 2020, please replace it with Morebits.string.escapeRegExp'); // eslint-disable-line no-console
return Morebits.string.escapeRegExp(text);
}
console.warnerror('NOTE: RegExp.escape from Morebits was deprecated September 2020, please replace it with mw.util.escapeRegExp'); // eslint-disable-line no-console
return mw.util.escapeRegExp(text);
};
Line 1,470:
Morebits.unbinder.prototype = {
/**
* Hide the region encapsulated by the `prefix` and `postfix` from string processing.
* string processing. `prefix` and `postfix` will be used in a
* RegExp, so items that need escaping should be use `\\`.
*
* @param {string} prefix
* @param {string} postfix
* @throws If either `prefix` or `postfix` is missing.
*/
unbind: function UnbinderUnbind(prefix, postfix) {
if (!prefix || !postfix) {
throw new Error('Both prefix and postfix must be provided');
}
var re = new RegExp(prefix + '([\\s\\S]*?)' + postfix, 'g');
this.content = this.content.replace(re, Morebits.unbinder.getCallback(this));
Line 1,849 ⟶ 1,855:
 
/**
* @deprecated in favor of Morebits.isPageRedirect as of November 2020
* @memberof Morebits.wiki
* @returns {boolean}
Line 1,947 ⟶ 1,953:
/* **************** Morebits.wiki.api **************** */
/**
* An easy way to talk to the MediaWiki API. Accepts either json or xml
* (default) formats; if json is selected, will default to `formatversion=2`
* unless otherwise specified. Similarly, enforces newer `errorformat`s,
* defaulting to `html` if unspecified. `uselang` enforced to the wiki's
* content language.
*
* In new code, the use of the last 3 parameters should be avoided, instead
* use {@link Morebits.wiki.api#setStatusElement|setStatusElement()} to bind
Line 2,779 ⟶ 2,790:
 
/**
* @deprecated UseAs of December 2020, use setWatchlist.
* @param {boolean} [watchlistOption=false] -
* - `True`: page watchlist status will be set based on the user's