jenkins-bot has submitted this change and it was merged.

Change subject: resourceloader: remove redundant mw.loader type-checks
......................................................................


resourceloader: remove redundant mw.loader type-checks

I searched Google and could not find any indication that anyone has encountered
these error messages in the wild since their introduction, half a decade go.
In my opinion they hurt readability substantially by displacing the main body
of the function away from its declaration.

Change-Id: Ifd33974b0c63f3d7ea44f1b0728de4b8b8dde099
---
M resources/src/mediawiki/mediawiki.js
1 file changed, 0 insertions(+), 27 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/src/mediawiki/mediawiki.js 
b/resources/src/mediawiki/mediawiki.js
index 348b617..40c5595 100644
--- a/resources/src/mediawiki/mediawiki.js
+++ b/resources/src/mediawiki/mediawiki.js
@@ -1744,10 +1744,6 @@
                                                }
                                                return;
                                        }
-                                       // Validate input
-                                       if ( typeof module !== 'string' ) {
-                                               throw new Error( 'module must 
be a string, not a ' + typeof module );
-                                       }
                                        if ( hasOwn.call( registry, module ) ) {
                                                throw new Error( 'module 
already registered: ' + module );
                                        }
@@ -1801,22 +1797,6 @@
                                 * @param {Object} [templates] List of 
key/value pairs to be added to mw#templates.
                                 */
                                implement: function ( module, script, style, 
messages, templates ) {
-                                       // Validate input
-                                       if ( typeof module !== 'string' ) {
-                                               throw new Error( 'module must 
be of type string, not ' + typeof module );
-                                       }
-                                       if ( script && !$.isFunction( script ) 
&& !$.isArray( script ) && typeof script !== 'string' ) {
-                                               throw new Error( 'script must 
be of type function, array, or script; not ' + typeof script );
-                                       }
-                                       if ( style && !$.isPlainObject( style ) 
) {
-                                               throw new Error( 'style must be 
of type object, not ' + typeof style );
-                                       }
-                                       if ( messages && !$.isPlainObject( 
messages ) ) {
-                                               throw new Error( 'messages must 
be of type object, not a ' + typeof messages );
-                                       }
-                                       if ( templates && !$.isPlainObject( 
templates ) ) {
-                                               throw new Error( 'templates 
must be of type object, not a ' + typeof templates );
-                                       }
                                        // Automatically register module
                                        if ( !hasOwn.call( registry, module ) ) 
{
                                                mw.loader.register( module );
@@ -1861,9 +1841,6 @@
                                        // Allow calling with a single 
dependency as a string
                                        if ( typeof dependencies === 'string' ) 
{
                                                dependencies = [ dependencies ];
-                                       } else if ( !$.isArray( dependencies ) 
) {
-                                               // Invalid input
-                                               throw new Error( 'Dependencies 
must be a string or an array' );
                                        }
 
                                        if ( ready ) {
@@ -1904,10 +1881,6 @@
                                load: function ( modules, type ) {
                                        var filtered, l;
 
-                                       // Validate input
-                                       if ( typeof modules !== 'object' && 
typeof modules !== 'string' ) {
-                                               throw new Error( 'modules must 
be a string or an array, not a ' + typeof modules );
-                                       }
                                        // Allow calling with a url or single 
dependency as a string
                                        if ( typeof modules === 'string' ) {
                                                // "https://example.org/x.js";, 
"http://example.org/x.js";, "//example.org/x.js", "/x.js"

-- 
To view, visit https://gerrit.wikimedia.org/r/295108
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifd33974b0c63f3d7ea44f1b0728de4b8b8dde099
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Edokter <er...@darcoury.nl>
Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to