Hygiene: Use [i] instead of charAt(i) for string index access
authorTimo Tijhof <krinklemail@gmail.com>
Mon, 22 Jun 2015 23:33:32 +0000 (00:33 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Mon, 22 Jun 2015 23:34:24 +0000 (00:34 +0100)
Was mostly this way for IE6 compatibility which is no longer
relevant for our JavaScript runtime.

Change-Id: I7c441c7b40f40bb2974c4da5ea9f7a87119e7462

resources/src/mediawiki.special/mediawiki.special.upload.js
resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js
resources/src/mediawiki/mediawiki.Title.js
resources/src/mediawiki/mediawiki.Uri.js
resources/src/mediawiki/mediawiki.userSuggest.js

index d0dfb28..ea1eb99 100644 (file)
                                fname = fname.replace( / /g, '_' );
                                // Capitalise first letter if needed
                                if ( mw.config.get( 'wgCapitalizeUploads' ) ) {
-                                       fname = fname.charAt( 0 ).toUpperCase().concat( fname.slice( 1 ) );
+                                       fname = fname[0].toUpperCase() + fname.slice( 1 );
                                }
 
                                // Output result
index 1bc1d3d..26b2f5d 100644 (file)
@@ -64,7 +64,7 @@
                }
 
                // Dont send leading ':' to open search
-               if ( value.charAt( 0 ) === ':' ) {
+               if ( value[0] === ':' ) {
                        value = value.slice( 1 );
                }
 
index 2fd7bfa..e46eca5 100644 (file)
                        .replace( rUnderscoreTrim, '' );
 
                // Process initial colon
-               if ( title !== '' && title.charAt( 0 ) === ':' ) {
+               if ( title !== '' && title[0] === ':' ) {
                        // Initial colon means main namespace instead of specified default
                        namespace = NS_MAIN;
                        title = title
                }
 
                // Any remaining initial :s are illegal.
-               if ( title.charAt( 0 ) === ':' ) {
+               if ( title[0] === ':' ) {
                        return false;
                }
 
                title = $.trim( title.replace( rWhitespace, ' ' ) );
 
                // Process initial colon
-               if ( title !== '' && title.charAt( 0 ) === ':' ) {
+               if ( title !== '' && title[0] === ':' ) {
                        // Initial colon means main namespace instead of specified default
                        namespace = NS_MAIN;
                        title = title
                getName: function () {
                        if ( $.inArray( this.namespace, mw.config.get( 'wgCaseSensitiveNamespaces' ) ) !== -1 ) {
                                return this.title;
-                       } else {
-                               return this.title.charAt( 0 ).toUpperCase() + this.title.slice( 1 );
                        }
+                       return this.title[0].toUpperCase() + this.title.slice( 1 );
                },
 
                /**
index abfb279..07d8900 100644 (file)
                                        this.port = defaultUri.port;
                                }
                        }
-                       if ( this.path && this.path.charAt( 0 ) !== '/' ) {
+                       if ( this.path && this.path[0] !== '/' ) {
                                // A real relative URL, relative to defaultUri.path. We can't really handle that since we cannot
                                // figure out whether the last path component of defaultUri.path is a directory or a file.
                                throw new Error( 'Bad constructor arguments' );
index 3964f0b..df10204 100644 (file)
@@ -15,7 +15,7 @@
                                list: 'allusers',
                                // Prefix of list=allusers is case sensitive. Normalise first
                                // character to uppercase so that "fo" may yield "Foo".
-                               auprefix: userInput.charAt( 0 ).toUpperCase() + userInput.slice( 1 ),
+                               auprefix: userInput[0].toUpperCase() + userInput.slice( 1 ),
                                aulimit: maxRows
                        } ).done( function ( data ) {
                                var users = $.map( data.query.allusers, function ( userObj ) {