mw.loader: Simplify getVersion and getState
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 21 Sep 2017 23:10:45 +0000 (00:10 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 21 Sep 2017 23:10:45 +0000 (00:10 +0100)
This undefined check no longer makes sense since there are now
defaults for these in register(). There is no supported scenario
in which a module would have a key in the registry but not
have these properties defined, or have them defined with
the undefined value.

Change-Id: I945871861ccf3659c2d7dd021aa87dfd747f22b9

resources/src/mediawiki/mediawiki.js

index b522486..7e02df4 100644 (file)
                                 *  in the registry.
                                 */
                                getVersion: function ( module ) {
-                                       if ( !hasOwn.call( registry, module ) || registry[ module ].version === undefined ) {
-                                               return null;
-                                       }
-                                       return registry[ module ].version;
+                                       return hasOwn.call( registry, module ) ? registry[ module ].version : null;
                                },
 
                                /**
                                 *  in the registry.
                                 */
                                getState: function ( module ) {
-                                       if ( !hasOwn.call( registry, module ) || registry[ module ].state === undefined ) {
-                                               return null;
-                                       }
-                                       return registry[ module ].state;
+                                       return hasOwn.call( registry, module ) ? registry[ module ].state : null;
                                },
 
                                /**