resourceloader: Undeprecate mw.Map#values
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 4 Mar 2017 00:36:46 +0000 (16:36 -0800)
committerKrinkle <krinklemail@gmail.com>
Mon, 6 Mar 2017 21:12:12 +0000 (21:12 +0000)
Follows-up dc0f9b3a3a, which renamed #values to #internalValues to ease
migration to ES5 Map where such object could no longer exist in
real-time as a plain object.

However ES5 Map for mw.Map is no longer on the roadmap per T146432.
The main reason for adopting ES5 was performance, which turns out
to be invalid and was merely a bug in V8 that has since been fixed.

Change this back and undeprecate it. If anything, for developer
convience and type-ahead, which is fairly wildely used.

Change-Id: Ic19641656e53068a0aa15c27f172d39eb13620dd

resources/src/mediawiki/mediawiki.js
tests/qunit/suites/resources/mediawiki/mediawiki.test.js

index 7872818..00b275f 100644 (file)
@@ -82,9 +82,8 @@
         *  copied in one direction only. Changes to globals do not reflect in the map.
         */
        function Map( global ) {
-               this.internalValues = {};
+               this.values = {};
                if ( global === true ) {
-
                        // Override #set to also set the global variable
                        this.set = function ( selection, value ) {
                                var s;
                                return false;
                        };
                }
-
-               // Deprecated since MediaWiki 1.28
-               log.deprecate(
-                       this,
-                       'values',
-                       this.internalValues,
-                       'mw.Map#values is deprecated. Use mw.Map#get() instead.',
-                       'Map-values'
-               );
        }
 
        /**
         * @param {Mixed} value
         */
        function setGlobalMapValue( map, key, value ) {
-               map.internalValues[ key ] = value;
+               map.values[ key ] = value;
                log.deprecate(
                                window,
                                key,
                        }
 
                        if ( typeof selection === 'string' ) {
-                               if ( !hasOwn.call( this.internalValues, selection ) ) {
-                                       return fallback;
-                               }
-                               return this.internalValues[ selection ];
+                               return hasOwn.call( this.values, selection ) ?
+                                       this.values[ selection ] :
+                                       fallback;
                        }
 
                        if ( selection === undefined ) {
-                               return this.internalValues;
+                               return this.values;
                        }
 
                        // Invalid selection key
 
                        if ( $.isPlainObject( selection ) ) {
                                for ( s in selection ) {
-                                       this.internalValues[ s ] = selection[ s ];
+                                       this.values[ s ] = selection[ s ];
                                }
                                return true;
                        }
                        if ( typeof selection === 'string' && arguments.length > 1 ) {
-                               this.internalValues[ selection ] = value;
+                               this.values[ selection ] = value;
                                return true;
                        }
                        return false;
                 * @return {boolean} True if the key(s) exist
                 */
                exists: function ( selection ) {
-                       var s;
-
+                       var i;
                        if ( $.isArray( selection ) ) {
-                               for ( s = 0; s < selection.length; s++ ) {
-                                       if ( typeof selection[ s ] !== 'string' || !hasOwn.call( this.internalValues, selection[ s ] ) ) {
+                               for ( i = 0; i < selection.length; i++ ) {
+                                       if ( typeof selection[ i ] !== 'string' || !hasOwn.call( this.values, selection[ i ] ) ) {
                                                return false;
                                        }
                                }
                                return true;
                        }
-                       return typeof selection === 'string' && hasOwn.call( this.internalValues, selection );
+                       return typeof selection === 'string' && hasOwn.call( this.values, selection );
                }
        };
 
index d3e73ae..697f32d 100644 (file)
                }, 'Map.get return includes keys that were not found as null values' );
 
                // Interacting with globals and accessing the values object
-               this.suppressWarnings();
                assert.strictEqual( conf.get(), conf.values, 'Map.get returns the entire values object by reference (if called without arguments)' );
-               this.restoreWarnings();
 
                conf.set( 'globalMapChecker', 'Hi' );