r91388 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91387‎ | r91388 | r91389 >
Date:23:24, 3 July 2011
Author:krinkle
Status:ok
Tags:
Comment:
Fix for the broken tests introduced in r91387.

Check input before assuming there are no arguments and the values object is expected.
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -40,7 +40,7 @@
4141 * If selection was an array, returns an object of key/values (value is null if not found),
4242 * If selection was not passed or invalid, will return the 'values' object member (be careful as
4343 * objects are always passed by reference in JavaScript!).
44 - * @return Map
 44+ * @return Values as a string or object, null if invalid/inexistant.
4545 */
4646 Map.prototype.get = function( selection, fallback ) {
4747 if ( $.isArray( selection ) ) {
@@ -59,7 +59,11 @@
6060 }
6161 return this.values[selection];
6262 }
63 - return this.values;
 63+ if ( selection === undefined ) {
 64+ return this.values;
 65+ } else {
 66+ return null; // invalid selection key
 67+ }
6468 };
6569
6670 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r91834Removing @broken comment. Not anymore, they don't as of r91388....krinkle15:27, 10 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91387Adding tests for expected reponse when passing invalid values to Map.get...krinkle23:22, 3 July 2011

Status & tagging log