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
* copied in one direction only. Changes to globals do not reflect in the map.
*/
function Map( global ) {
* copied in one direction only. Changes to globals do not reflect in the map.
*/
function Map( global ) {
- this.internalValues = {};
// Override #set to also set the global variable
this.set = function ( selection, value ) {
var s;
// Override #set to also set the global variable
this.set = function ( selection, value ) {
var s;
-
- // 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 ) {
* @param {Mixed} value
*/
function setGlobalMapValue( map, key, value ) {
- map.internalValues[ key ] = value;
+ map.values[ key ] = value;
log.deprecate(
window,
key,
log.deprecate(
window,
key,
}
if ( typeof selection === 'string' ) {
}
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 ) {
}
if ( selection === undefined ) {
- return this.internalValues;
}
// Invalid selection key
}
// Invalid selection key
if ( $.isPlainObject( selection ) ) {
for ( s in selection ) {
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 ) {
}
return true;
}
if ( typeof selection === 'string' && arguments.length > 1 ) {
- this.internalValues[ selection ] = value;
+ this.values[ selection ] = value;
return true;
}
return false;
return true;
}
return false;
* @return {boolean} True if the key(s) exist
*/
exists: function ( selection ) {
* @return {boolean} True if the key(s) exist
*/
exists: function ( selection ) {
if ( $.isArray( selection ) ) {
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 false;
}
}
return true;
}
- return typeof selection === 'string' && hasOwn.call( this.internalValues, selection );
+ return typeof selection === 'string' && hasOwn.call( this.values, selection );
}, 'Map.get return includes keys that were not found as null values' );
// Interacting with globals and accessing the values object
}, '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)' );
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' );
conf.set( 'globalMapChecker', 'Hi' );