Fix for the broken tests introduced in r91387.
authorKrinkle <krinkle@users.mediawiki.org>
Sun, 3 Jul 2011 23:24:51 +0000 (23:24 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Sun, 3 Jul 2011 23:24:51 +0000 (23:24 +0000)
Check input before assuming there are no arguments and the values object is expected.

resources/mediawiki/mediawiki.js

index 63e9e29..28a57a2 100644 (file)
@@ -40,7 +40,7 @@ window.mediaWiki = new ( function( $ ) {
         * If selection was an array, returns an object of key/values (value is null if not found),
         * If selection was not passed or invalid, will return the 'values' object member (be careful as
         * objects are always passed by reference in JavaScript!).
-        * @return Map
+        * @return Values as a string or object, null if invalid/inexistant.
         */
        Map.prototype.get = function( selection, fallback ) {
                if ( $.isArray( selection ) ) {
@@ -59,7 +59,11 @@ window.mediaWiki = new ( function( $ ) {
                        }
                        return this.values[selection];
                }
-               return this.values;
+               if ( selection === undefined ) {
+                       return this.values;
+               } else {
+                       return null; // invalid selection key
+               }
        };
 
        /**