The optional 'dependencies' parameter is only ever used with
an array of strings, never just as a string.
Also fix the missing square-brackets around the parameter name
in the documentation that indicate the parameter as optional.
The code was already allowing it to be missing, and the server
does indeed omit it when a module has no dependencies.
(See ResourceLoaderStartupModuleTest for confirmation of that).
The server-side methods ResourceLoaderModule::getDependencies
and ResourceLoader::makeLoaderRegisterScript already don't
support string-type for this parameter.
Change-Id: I80a1e4b2eefb62e669c031e0d953bf74a9623264
* a list of arguments compatible with this method
* @param {string|number} version Module version hash (falls backs to empty string)
* Can also be a number (timestamp) for compatibility with MediaWiki 1.25 and earlier.
* a list of arguments compatible with this method
* @param {string|number} version Module version hash (falls backs to empty string)
* Can also be a number (timestamp) for compatibility with MediaWiki 1.25 and earlier.
- * @param {string|Array} dependencies One string or array of strings of module
- * names on which this module depends.
+ * @param {string[]} [dependencies] Array of module names on which this module depends.
* @param {string} [group=null] Group which the module is in
* @param {string} [source='local'] Name of the source
* @param {string} [skip=null] Script body of the skip function
*/
register: function ( module, version, dependencies, group, source, skip ) {
* @param {string} [group=null] Group which the module is in
* @param {string} [source='local'] Name of the source
* @param {string} [skip=null] Script body of the skip function
*/
register: function ( module, version, dependencies, group, source, skip ) {
// Allow multiple registration
if ( typeof module === 'object' ) {
resolveIndexedDependencies( module );
// Allow multiple registration
if ( typeof module === 'object' ) {
resolveIndexedDependencies( module );
if ( hasOwn.call( registry, module ) ) {
throw new Error( 'module already registered: ' + module );
}
if ( hasOwn.call( registry, module ) ) {
throw new Error( 'module already registered: ' + module );
}
- if ( typeof dependencies === 'string' ) {
- // A single module name
- deps = [ dependencies ];
- } else if ( typeof dependencies === 'object' ) {
- // Array of module names
- deps = dependencies;
- }
// List the module as registered
registry[ module ] = {
// Exposed to execute() for mw.loader.implement() closures.
// List the module as registered
registry[ module ] = {
// Exposed to execute() for mw.loader.implement() closures.
exports: {}
},
version: String( version || '' ),
exports: {}
},
version: String( version || '' ),
- dependencies: deps || [],
+ dependencies: dependencies || [],
group: typeof group === 'string' ? group : null,
source: typeof source === 'string' ? source : 'local',
state: 'registered',
group: typeof group === 'string' ? group : null,
source: typeof source === 'string' ? source : 'local',
state: 'registered',