From: Timo Tijhof Date: Mon, 23 Apr 2018 18:47:59 +0000 (+0100) Subject: resourceloader: Remove remnants of "dependencies as a function" X-Git-Tag: 1.34.0-rc.0~5537^2 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=2f173f78ed721df454599cf5871754bbf133c8a9;p=lhc%2Fweb%2Fwiklou.git resourceloader: Remove remnants of "dependencies as a function" This hasn't been used in a while, at least two years from what I could find. It also doesn't have tests, and numerous paths that possibly should handle it, don't. This was originally implemented for TMH as a way to dynamically change what it loads based on the browser environment. However, this has been addressed by two other aspects already: * mw.loader.using() - During development of ResourceLoader, this method was unstable for a short while. During that pre-release time, dynamic dependencies was added as workaround for TMH. It being stable addresses TMH's use case of loading *different* modules (with callback) based on environment factors. This allows complete mutation of the array passed: remove, replace, and add operations. This can be used to completely change was a module does based on browser environment, e.g. load a decoder for X instead of Y, but places the logic in the startup module, which is inefficient. TMH has switched long ago to using using() instead. * 'skipFunction' - Introduced in more recent years, this was added to more efficiently address the 'remove' use case. E.g. where the 'needs' are consistent between browsers, but a subset of the needs may be available natively without needing a polyfil. The skipFunction allows once to mark a module as "ready" without actually loading anything. This has been used for efficient and conditional loading of DOM2, JSON and ES5 polyfills. (All of which have been removed since, but that's a separate story.) Bug: T192623 Change-Id: Ia97df72a0c3f0fc0dc917fce0a94213b23db4daa --- diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index 3fe276bbef..6a2478cfd2 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -782,7 +782,7 @@ * 'moduleName': { * // From mw.loader.register() * 'version': '########' (hash) - * 'dependencies': ['required.foo', 'bar.also', ...], (or) function () {} + * 'dependencies': ['required.foo', 'bar.also', ...] * 'group': 'somegroup', (or) null * 'source': 'local', (or) 'anotherwiki' * 'skip': 'return !!window.Example', (or) null @@ -1121,14 +1121,6 @@ } } - // Resolves dynamic loader function and replaces it with its own results - if ( typeof registry[ module ].dependencies === 'function' ) { - registry[ module ].dependencies = registry[ module ].dependencies(); - // Ensures the module's dependencies are always in an array - if ( typeof registry[ module ].dependencies !== 'object' ) { - registry[ module ].dependencies = [ registry[ module ].dependencies ]; - } - } if ( resolved.indexOf( module ) !== -1 ) { // Module already resolved; nothing to do return; @@ -1891,8 +1883,8 @@ * 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|Function} dependencies One string or array of strings of module - * names on which this module depends, or a function that returns that array. + * @param {string|Array} dependencies One string or array of strings 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 @@ -1919,8 +1911,8 @@ if ( typeof dependencies === 'string' ) { // A single module name deps = [ dependencies ]; - } else if ( typeof dependencies === 'object' || typeof dependencies === 'function' ) { - // Array of module names or a function that returns an array + } else if ( typeof dependencies === 'object' ) { + // Array of module names deps = dependencies; } // List the module as registered