Mobrovac has submitted this change and it was merged.

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


Fix isEmpty util

isEmpty always returns true 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, 11 insertions(+), 1 deletion(-)

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



diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index 6c0db3d..c1676d3 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -3,7 +3,17 @@
 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, an empty array, or
+ *          an empty string.
+ */
+function isEmpty(val) {
+  return !underscore.isNumber(val)
+      && !underscore.isBoolean(val)
+      && 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: merged
Gerrit-Change-Id: I13bc669471106548ae401c885766fb92fc0cb3f4
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Dbrant <[email protected]>
Gerrit-Reviewer: Fjalapeno <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Mholloway <[email protected]>
Gerrit-Reviewer: Mhurd <[email protected]>
Gerrit-Reviewer: Mobrovac <[email protected]>
Gerrit-Reviewer: Niedzielski <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to