Niedzielski has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/289328

Change subject: Fix isEmpty util
......................................................................

Fix isEmpty util

isEmpty always returns false for booleans (even true) and numbers (even
nonzero) which may be unexpected. Return false for these types instead.

Change-Id: I13bc669471106548ae401c885766fb92fc0cb3f4
---
M lib/mobile-util.js
1 file changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/28/289328/1

diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index 6c0db3d..7a438cc 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -3,7 +3,16 @@
 var underscore = require('underscore');
 var uuid = require('cassandra-uuid').TimeUuid;
 
-var isNonempty = underscore.negate(underscore.isEmpty);
+/**
+ *@returns true if val is null, undefined, an empty object, or an empty array.
+ */
+function isEmpty(val) {
+  return typeof val !== 'number'
+      && typeof val !== 'boolean'
+      && underscore.isEmpty(val);
+}
+
+var isNonempty = underscore.negate(isEmpty);
 
 /**
  * @param [fallback]

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I13bc669471106548ae401c885766fb92fc0cb3f4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org>

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

Reply via email to