Reedy has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/184713

Change subject: Revert "mw.config: Show deprecation notices when accessing 
globals"
......................................................................

Revert "mw.config: Show deprecation notices when accessing globals"

This reverts commit 24f84b08cf91efd51cd95380e2eec155d24a2d03.

It upset JS on commons majorly

Change-Id: Ibc2aa58b4eb6ddeeaf95a93f998c6a02f490f642
---
M resources/src/mediawiki/mediawiki.js
M tests/qunit/suites/resources/mediawiki/mediawiki.test.js
2 files changed, 9 insertions(+), 73 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/13/184713/1

diff --git a/resources/src/mediawiki/mediawiki.js 
b/resources/src/mediawiki/mediawiki.js
index 6bf93f4..94b64b9 100644
--- a/resources/src/mediawiki/mediawiki.js
+++ b/resources/src/mediawiki/mediawiki.js
@@ -79,56 +79,12 @@
         * @class mw.Map
         *
         * @constructor
-        * @param {Object|boolean} [values] Value-bearing object to map, 
defaults to an empty object.
-        *  For backwards-compatibility with mw.config, this can also be `true` 
in which case values
-        *  will be copied to the Window object as global variables (T72470). 
Values are copied in one
-        *  direction only. Changes to globals are not reflected in the map.
+        * @param {Object|boolean} [values] Value-bearing object to map, or 
boolean
+        *  true to map over the global object. Defaults to an empty object.
         */
        function Map( values ) {
-               if ( values === true ) {
-                       this.values = {};
-
-                       // Override #set to also set the global variable
-                       this.set = function ( selection, value ) {
-                               var s;
-
-                               if ( $.isPlainObject( selection ) ) {
-                                       for ( s in selection ) {
-                                               setGlobalMapValue( this, s, 
selection[s] );
-                                       }
-                                       return true;
-                               }
-                               if ( typeof selection === 'string' && 
arguments.length ) {
-                                       setGlobalMapValue( this, selection, 
value );
-                                       return true;
-                               }
-                               return false;
-                       };
-
-                       return;
-               }
-
-               this.values = values || {};
-       }
-
-       /**
-        * Alias property to the global object.
-        *
-        * @private
-        * @static
-        * @param {mw.Map} map
-        * @param {string} key
-        * @param {Mixed} value
-        */
-       function setGlobalMapValue( map, key, value ) {
-               map.values[key] = value;
-               mw.log.deprecate(
-                       window,
-                       key,
-                       value,
-                       // Deprecation notice for mw.config globals (T58550, 
T72470)
-                       map === mw.config && 'Use mw.config instead.'
-               );
+               this.values = values === true ? window : ( values || {} );
+               return this;
        }
 
        Map.prototype = {
@@ -180,7 +136,7 @@
                 *
                 * @param {string|Object} selection String key to set value 
for, or object mapping keys to values.
                 * @param {Mixed} [value] Value to set (optional, only in use 
when key is a string)
-                * @return {boolean} This returns true on success, false on 
failure.
+                * @return {Boolean} This returns true on success, false on 
failure.
                 */
                set: function ( selection, value ) {
                        var s;
@@ -191,7 +147,7 @@
                                }
                                return true;
                        }
-                       if ( typeof selection === 'string' && arguments.length 
) {
+                       if ( typeof selection === 'string' && arguments.length 
> 1 ) {
                                this.values[selection] = value;
                                return true;
                        }
@@ -626,7 +582,6 @@
                                        } );
                                } catch ( err ) {
                                        // IE8 can throw on 
Object.defineProperty
-                                       // Create a copy of the value to the 
object.
                                        obj[key] = val;
                                }
                        };
diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.test.js 
b/tests/qunit/suites/resources/mediawiki/mediawiki.test.js
index 6c8c62f..87520bd 100644
--- a/tests/qunit/suites/resources/mediawiki/mediawiki.test.js
+++ b/tests/qunit/suites/resources/mediawiki/mediawiki.test.js
@@ -55,7 +55,7 @@
                this.restoreWarnings();
        } );
 
-       QUnit.test( 'mw.Map', 34, function ( assert ) {
+       QUnit.test( 'mw.Map', 28, function ( assert ) {
                var arry, conf, funky, globalConf, nummy, someValues;
 
                conf = new mw.Map();
@@ -126,31 +126,12 @@
 
                conf.set( 'globalMapChecker', 'Hi' );
 
-               assert.ok( ( 'globalMapChecker' in window ) === false, 'Map 
does not its store values in the window object by default' );
+               assert.ok( 'globalMapChecker' in window === false, 'new mw.Map 
did not store its values in the global window object by default' );
 
                globalConf = new mw.Map( true );
                globalConf.set( 'anotherGlobalMapChecker', 'Hello' );
 
-               assert.ok( 'anotherGlobalMapChecker' in window, 'global Map 
stores its values in the window object' );
-
-               assert.equal( globalConf.get( 'anotherGlobalMapChecker' ), 
'Hello', 'get value from global Map via get()' );
-               this.suppressWarnings();
-               assert.equal( window.anotherGlobalMapChecker, 'Hello', 'get 
value from global Map via window object' );
-               this.restoreWarnings();
-
-               // Change value via global Map
-               globalConf.set('anotherGlobalMapChecker', 'Again');
-               assert.equal( globalConf.get( 'anotherGlobalMapChecker' ), 
'Again', 'Change in global Map reflected via get()' );
-               this.suppressWarnings();
-               assert.equal( window.anotherGlobalMapChecker, 'Again', 'Change 
in global Map reflected window object' );
-               this.restoreWarnings();
-
-               // Change value via window object
-               this.suppressWarnings();
-               window.anotherGlobalMapChecker = 'World';
-               assert.equal( window.anotherGlobalMapChecker, 'World', 'Change 
in window object works' );
-               this.restoreWarnings();
-               assert.equal( globalConf.get( 'anotherGlobalMapChecker' ), 
'Again', 'Change in window object not reflected in global Map' );
+               assert.ok( 'anotherGlobalMapChecker' in window, 'new mw.Map( 
true ) did store its values in the global window object' );
 
                // Whitelist this global variable for QUnit's 'noglobal' mode
                if ( QUnit.config.noglobals ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/184713
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc2aa58b4eb6ddeeaf95a93f998c6a02f490f642
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to