Remove use of $.escapeRE in favour of mw.RegExp.escape
Removes dependency on the generic jquery.mwExtension module I wrote in 2011 which has rotten and contains largely unused utilities. Change-Id: Id7025dc2be958840735f4a9a5b020bd876011740
This commit is contained in:
parent
8bee338d1c
commit
4559185ae8
8 changed files with 19 additions and 19 deletions
|
|
@ -148,7 +148,7 @@ return array(
|
|||
'scripts' => 'resources/src/jquery/jquery.accessKeyLabel.js',
|
||||
'dependencies' => array(
|
||||
'jquery.client',
|
||||
'jquery.mwExtension',
|
||||
'mediawiki.RegExp',
|
||||
),
|
||||
'messages' => array( 'brackets', 'word-separator' ),
|
||||
'targets' => array( 'mobile', 'desktop' ),
|
||||
|
|
@ -247,7 +247,7 @@ return array(
|
|||
),
|
||||
'jquery.highlightText' => array(
|
||||
'scripts' => 'resources/src/jquery/jquery.highlightText.js',
|
||||
'dependencies' => 'jquery.mwExtension',
|
||||
'dependencies' => 'mediawiki.RegExp',
|
||||
'targets' => array( 'desktop', 'mobile' ),
|
||||
),
|
||||
'jquery.hoverIntent' => array(
|
||||
|
|
@ -309,7 +309,7 @@ return array(
|
|||
'styles' => 'resources/src/jquery/jquery.tablesorter.css',
|
||||
'messages' => array( 'sort-descending', 'sort-ascending' ),
|
||||
'dependencies' => array(
|
||||
'jquery.mwExtension',
|
||||
'mediawiki.RegExp',
|
||||
'mediawiki.language.months',
|
||||
),
|
||||
),
|
||||
|
|
@ -954,7 +954,7 @@ return array(
|
|||
'mediawiki.htmlform' => array(
|
||||
'scripts' => 'resources/src/mediawiki/mediawiki.htmlform.js',
|
||||
'dependencies' => array(
|
||||
'jquery.mwExtension',
|
||||
'mediawiki.RegExp',
|
||||
'jquery.byteLimit',
|
||||
),
|
||||
'messages' => array(
|
||||
|
|
@ -978,6 +978,7 @@ return array(
|
|||
'scripts' => 'resources/src/mediawiki/mediawiki.inspect.js',
|
||||
'dependencies' => array(
|
||||
'jquery.byteLength',
|
||||
'mediawiki.RegExp',
|
||||
'json',
|
||||
),
|
||||
'targets' => array( 'desktop', 'mobile' ),
|
||||
|
|
@ -1089,7 +1090,7 @@ return array(
|
|||
'scripts' => 'resources/src/mediawiki/mediawiki.util.js',
|
||||
'dependencies' => array(
|
||||
'jquery.accessKeyLabel',
|
||||
'jquery.mwExtension',
|
||||
'mediawiki.RegExp',
|
||||
'mediawiki.notify',
|
||||
),
|
||||
'position' => 'top', // For $wgPreloadJavaScriptMwUtil
|
||||
|
|
@ -1381,7 +1382,7 @@ return array(
|
|||
'mediawiki.page.startup',
|
||||
'mediawiki.util',
|
||||
'jquery.accessKeyLabel',
|
||||
'jquery.mwExtension',
|
||||
'mediawiki.RegExp',
|
||||
),
|
||||
'messages' => array(
|
||||
'watch',
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ function getAccessKeyLabel( element ) {
|
|||
*/
|
||||
function updateTooltipOnElement( element, titleElement ) {
|
||||
var array = ( mw.msg( 'word-separator' ) + mw.msg( 'brackets' ) ).split( '$1' ),
|
||||
regexp = new RegExp( $.map( array, $.escapeRE ).join( '.*?' ) + '$' ),
|
||||
regexp = new RegExp( $.map( array, mw.RegExp.escape ).join( '.*?' ) + '$' ),
|
||||
oldTitle = titleElement.title,
|
||||
rawTitle = oldTitle.replace( regexp, '' ),
|
||||
newTitle = rawTitle,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* TODO: Add a function for restoring the previous text.
|
||||
* TODO: Accept mappings for converting shortcuts like WP: to Wikipedia:.
|
||||
*/
|
||||
( function ( $ ) {
|
||||
( function ( $, mw ) {
|
||||
|
||||
$.highlightText = {
|
||||
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
// non latin characters can make regex think a new word has begun: do not use \b
|
||||
// http://stackoverflow.com/questions/3787072/regex-wordwrap-with-utf8-characters-in-js
|
||||
// look for an occurrence of our pattern and store the starting position
|
||||
match = node.data.match( new RegExp( '(^|\\s)' + $.escapeRE( pat ), 'i' ) );
|
||||
match = node.data.match( new RegExp( '(^|\\s)' + mw.RegExp.escape( pat ), 'i' ) );
|
||||
if ( match ) {
|
||||
pos = match.index + match[1].length; // include length of any matched spaces
|
||||
// create the span wrapper for the matched text
|
||||
|
|
@ -70,4 +70,4 @@
|
|||
} );
|
||||
};
|
||||
|
||||
}( jQuery ) );
|
||||
}( jQuery, mediaWiki ) );
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@
|
|||
// Construct regex for number identification
|
||||
for ( i = 0; i < ascii.length; i++ ) {
|
||||
ts.transformTable[localised[i]] = ascii[i];
|
||||
digits.push( $.escapeRE( localised[i] ) );
|
||||
digits.push( mw.RegExp.escape( localised[i] ) );
|
||||
}
|
||||
}
|
||||
digitClass = '[' + digits.join( '', digits ) + ']';
|
||||
|
|
@ -518,13 +518,13 @@
|
|||
for ( i = 0; i < 12; i++ ) {
|
||||
name = mw.language.months.names[i].toLowerCase();
|
||||
ts.monthNames[name] = i + 1;
|
||||
regex.push( $.escapeRE( name ) );
|
||||
regex.push( mw.RegExp.escape( name ) );
|
||||
name = mw.language.months.genitive[i].toLowerCase();
|
||||
ts.monthNames[name] = i + 1;
|
||||
regex.push( $.escapeRE( name ) );
|
||||
regex.push( mw.RegExp.escape( name ) );
|
||||
name = mw.language.months.abbrev[i].toLowerCase().replace( '.', '' );
|
||||
ts.monthNames[name] = i + 1;
|
||||
regex.push( $.escapeRE( name ) );
|
||||
regex.push( mw.RegExp.escape( name ) );
|
||||
}
|
||||
|
||||
// Build piped string
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
if ( actionPaths.hasOwnProperty( key ) ) {
|
||||
parts = actionPaths[key].split( '$1' );
|
||||
for ( i = 0; i < parts.length; i++ ) {
|
||||
parts[i] = $.escapeRE( parts[i] );
|
||||
parts[i] = mw.RegExp.escape( parts[i] );
|
||||
}
|
||||
m = new RegExp( parts.join( '(.+)' ) ).exec( url );
|
||||
if ( m && m[1] ) {
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@
|
|||
$ul = $( this ).prev( 'ul.mw-htmlform-cloner-ul' );
|
||||
|
||||
html = $ul.data( 'template' ).replace(
|
||||
new RegExp( $.escapeRE( $ul.data( 'uniqueId' ) ), 'g' ),
|
||||
new RegExp( mw.RegExp.escape( $ul.data( 'uniqueId' ) ), 'g' ),
|
||||
'clone' + ( ++cloneCounter )
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -261,8 +261,7 @@
|
|||
*/
|
||||
grep: function ( pattern ) {
|
||||
if ( typeof pattern.test !== 'function' ) {
|
||||
// Based on Y.Escape.regex from YUI v3.15.0
|
||||
pattern = new RegExp( pattern.replace( /[\-$\^*()+\[\]{}|\\,.?\s]/g, '\\$&' ), 'g' );
|
||||
pattern = new RegExp( mw.RegExp.escape( pattern ), 'g' );
|
||||
}
|
||||
|
||||
return $.grep( inspect.getLoadedModules(), function ( moduleName ) {
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@
|
|||
url = location.href;
|
||||
}
|
||||
// Get last match, stop at hash
|
||||
var re = new RegExp( '^[^#]*[&?]' + $.escapeRE( param ) + '=([^&#]*)' ),
|
||||
var re = new RegExp( '^[^#]*[&?]' + mw.RegExp.escape( param ) + '=([^&#]*)' ),
|
||||
m = re.exec( url );
|
||||
if ( m ) {
|
||||
// Beware that decodeURIComponent is not required to understand '+'
|
||||
|
|
|
|||
Loading…
Reference in a new issue