*/
/* global mwNow */
-/* eslint-disable no-use-before-define */
( function ( $ ) {
'use strict';
}() );
}
+ /**
+ * Alias property to the global object.
+ *
+ * @private
+ * @static
+ * @member mw.Map
+ * @param {mw.Map} map
+ * @param {string} key
+ * @param {Mixed} value
+ */
+ function setGlobalMapValue( map, key, value ) {
+ map.values[ key ] = value;
+ log.deprecate(
+ window,
+ key,
+ value,
+ // Deprecation notice for mw.config globals (T58550, T72470)
+ map === mw.config && 'Use mw.config instead.'
+ );
+ }
+
/**
* Create an object that can be read from or written to via methods that allow
* interaction both with single and multiple properties at once.
}
}
- /**
- * 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;
- log.deprecate(
- window,
- key,
- value,
- // Deprecation notice for mw.config globals (T58550, T72470)
- map === mw.config && 'Use mw.config instead.'
- );
- }
-
Map.prototype = {
constructor: Map,
mw.loader.store.set( module, registry[ module ] );
for ( m in registry ) {
if ( registry[ m ].state === 'loaded' && allReady( registry[ m ].dependencies ) ) {
+ // eslint-disable-next-line no-use-before-define
execute( m );
}
}
}
}
+ /**
+ * @private
+ * @param {Object} params Map of parameter names to values
+ * @return {string}
+ */
+ function makeQueryString( params ) {
+ return Object.keys( params ).map( function ( key ) {
+ return encodeURIComponent( key ) + '=' + encodeURIComponent( params[ key ] );
+ } ).join( '&' );
+ }
+
/**
* Create network requests for a batch of modules.
*
// combining versions from the module query string in-order. (T188076)
query.version = getCombinedVersion( packed.list );
query = sortQuery( query );
- addScript( sourceLoadScript + '?' + $.param( query ) );
+ addScript( sourceLoadScript + '?' + makeQueryString( query ) );
}
if ( !batch.length ) {
// > '&modules='.length === 9
// > '&version=1234567'.length === 16
// > 9 + 16 = 25
- currReqBaseLength = $.param( currReqBase ).length + 25;
+ currReqBaseLength = makeQueryString( currReqBase ).length + 25;
// We may need to split up the request to honor the query string length limit,
// so build it piece by piece.
return registry[ moduleName ].module.exports;
},
- /**
- * @inheritdoc mw.inspect#runReports
- * @method
- */
- inspect: function () {
- var args = slice.call( arguments );
- mw.loader.using( 'mediawiki.inspect', function () {
- mw.inspect.runReports.apply( mw.inspect, args );
- } );
- },
-
/**
* On browsers that implement the localStorage API, the module store serves as a
* smart complement to the browser cache. Unlike the browser cache, the module store
mw.trackSubscribe( 'resourceloader.exception', logError );
mw.trackSubscribe( 'resourceloader.assert', logError );
- /**
- * Fired when all modules associated with the page have finished loading.
- *
- * @event resourceloader_loadEnd
- * @member mw.hook
- */
- $( function () {
- var loading, modules;
-
- modules = mw.loader.getModuleNames().filter( function ( module ) {
- return mw.loader.getState( module ) === 'loading';
- } );
- // We only need a callback, not any actual module. First try a single using()
- // for all loading modules. If one fails, fall back to tracking each module
- // separately via $.when(), this is expensive.
- loading = mw.loader.using( modules ).catch( function () {
- var all = modules.map( function ( module ) {
- return mw.loader.using( module ).catch( function () {
- return $.Deferred().resolve();
- } );
- } );
- return $.when.apply( $, all );
- } );
- loading.then( function () {
- if ( window.performance && performance.mark ) {
- performance.mark( 'mwLoadEnd' );
- }
- mw.hook( 'resourceloader.loadEnd' ).fire();
- } );
- } );
-
// Attach to window and globally alias
window.mw = window.mediaWiki = mw;
}( jQuery ) );