'use strict';
var mw, StringSet, log,
- hasOwn = Object.prototype.hasOwnProperty,
trackQueue = [];
/**
* @property
* @private
*/
- var registry = {},
+ var registry = Object.create( null ),
// Mapping of sources, keyed by source-id, values are strings.
//
// Format:
// 'sourceId': 'http://example.org/w/load.php'
// }
//
- sources = {},
+ sources = Object.create( null ),
// For queueModuleScript()
handlingPendingRequests = false,
function sortDependencies( module, resolved, unresolved ) {
var i, deps, skip;
- if ( !hasOwn.call( registry, module ) ) {
+ if ( !( module in registry ) ) {
throw new Error( 'Unknown dependency: ' + module );
}
* or null if the module does not exist
*/
function getModuleKey( module ) {
- return hasOwn.call( registry, module ) ?
- ( module + '@' + registry[ module ].version ) : null;
+ return module in registry ? ( module + '@' + registry[ module ].version ) : null;
}
/**
* @param {string} [skip]
*/
function registerOne( module, version, dependencies, group, source, skip ) {
- if ( hasOwn.call( registry, module ) ) {
+ if ( module in registry ) {
throw new Error( 'module already registered: ' + module );
}
registry[ module ] = {
// Appends a list of modules from the queue to the batch
for ( q = 0; q < queue.length; q++ ) {
// Only load modules which are registered
- if ( hasOwn.call( registry, queue[ q ] ) && registry[ queue[ q ] ].state === 'registered' ) {
+ if ( queue[ q ] in registry && registry[ queue[ q ] ].state === 'registered' ) {
// Prevent duplicate entries
if ( batch.indexOf( queue[ q ] ) === -1 ) {
batch.push( queue[ q ] );
addSource: function ( ids ) {
var id;
for ( id in ids ) {
- if ( hasOwn.call( sources, id ) ) {
+ if ( id in sources ) {
throw new Error( 'source already registered: ' + id );
}
sources[ id ] = ids[ id ];
name = split.name,
version = split.version;
// Automatically register module
- if ( !hasOwn.call( registry, name ) ) {
+ if ( !( name in registry ) ) {
mw.loader.register( name );
}
// Check for duplicate implementation
var module, state;
for ( module in states ) {
state = states[ module ];
- if ( !hasOwn.call( registry, module ) ) {
+ if ( !( module in registry ) ) {
mw.loader.register( module );
}
setAndPropagate( module, state );
* in the registry.
*/
getVersion: function ( module ) {
- return hasOwn.call( registry, module ) ? registry[ module ].version : null;
+ return module in registry ? registry[ module ].version : null;
},
/**
* in the registry.
*/
getState: function ( module ) {
- return hasOwn.call( registry, module ) ? registry[ module ].state : null;
+ return module in registry ? registry[ module ].state : null;
},
/**