* @class mw
*/
mw = {
- redefineFallbacksForTest: function () {
- if ( !window.QUnit ) {
- throw new Error( 'Not allowed' );
- }
- defineFallbacks();
- },
+ redefineFallbacksForTest: window.QUnit && defineFallbacks,
/**
* Get the current time, measured in milliseconds since January 1, 1970 (UTC).
*/
config: new Map( $VARS.wgLegacyJavaScriptGlobals ),
- /**
- * Empty object for third-party libraries, for cases where you don't
- * want to add a new global, or the global is bad and needs containment
- * or wrapping.
- *
- * @property
- */
- libs: {},
-
/**
* Store for messages.
*
}
if ( !hasOwn.call( scriptFiles, fileName ) ) {
- throw new Error( 'Cannot require() undefined file ' + fileName );
+ throw new Error( 'Cannot require undefined file ' + fileName );
}
if ( hasOwn.call( moduleObj.packageExports, fileName ) ) {
// File has already been executed, return the cached result
dependencies.forEach( function ( module ) {
// Only queue modules that are still in the initial 'registered' state
- // (not ones already loading, ready or error).
+ // (e.g. not ones already loading or loaded etc.).
if ( registry[ module ].state === 'registered' && queue.indexOf( module ) === -1 ) {
- // Private modules must be embedded in the page. Don't bother queuing
- // these as the server will deny them anyway (T101806).
- if ( registry[ module ].group === 'private' ) {
- setAndPropagate( module, 'error' );
- } else {
- queue.push( module );
- }
+ queue.push( module );
}
} );
cssPending = 0;
if ( registry[ module ].state !== 'loaded' ) {
- throw new Error( 'Module in state "' + registry[ module ].state + '" may not be executed: ' + module );
+ throw new Error( 'Module in state "' + registry[ module ].state + '" may not execute: ' + module );
}
registry[ module ].state = 'executing';
} else {
mainScript = script.files[ script.main ];
if ( typeof mainScript !== 'function' ) {
- throw new Error( 'Main file ' + script.main + ' in module ' + module +
- ' must be of type function, found ' + typeof mainScript );
+ throw new Error( 'Main file in module ' + module + ' must be a function' );
}
// jQuery parameters are not passed for multi-file modules
mainScript(
* @param {string} [type='text/javascript'] MIME type to use if calling with a URL of an
* external script or style; acceptable values are "text/css" and
* "text/javascript"; if no type is provided, text/javascript is assumed.
+ * @throws {Error} If type is invalid
*/
load: function ( modules, type ) {
if ( typeof modules === 'string' && /^(https?:)?\/?\//.test( modules ) ) {
addScript( modules );
} else {
// Unknown type
- throw new Error( 'type must be text/css or text/javascript, found ' + type );
+ throw new Error( 'Invalid type ' + type );
}
} else {
// One or more modules
* @property {mw.Map}
*/
tokens: new Map()
- },
-
- // OOUI widgets specific to MediaWiki
- widgets: {}
+ }
};