cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [5/37] js commit: [all] Use type-coercion for booleans in Camera
Date Tue, 29 Jan 2013 19:07:52 GMT
[all] Use type-coercion for booleans in Camera

The reverts a change to argscheck that converts "true" to true. This
unsafe if the parameter is not actually a boolean, but instead a string.

This also changes the behaviour of negative numbers that were passed to
the boolean Camera arguments. Negative numbers will no longer be treated
as false.

Related to https://issues.apache.org/jira/browse/CB-2165


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/50be7a3c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/50be7a3c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/50be7a3c

Branch: refs/heads/symbolmapping
Commit: 50be7a3c5f4115fde47de2fd8226d14412ce61d2
Parents: f017682
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Fri Jan 18 13:22:28 2013 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Fri Jan 18 13:22:28 2013 -0500

----------------------------------------------------------------------
 lib/common/argscheck.js     |    1 -
 lib/common/plugin/Camera.js |    6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/50be7a3c/lib/common/argscheck.js
----------------------------------------------------------------------
diff --git a/lib/common/argscheck.js b/lib/common/argscheck.js
index dfe401c..524b435 100644
--- a/lib/common/argscheck.js
+++ b/lib/common/argscheck.js
@@ -72,7 +72,6 @@ function checkArgs(spec, functionName, args, opt_callee) {
 }
 
 function getValue(value, defaultValue) {
-    if (value !== undefined && value === "true") { value = true; }
     return value === undefined ? defaultValue : value;
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/50be7a3c/lib/common/plugin/Camera.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/Camera.js b/lib/common/plugin/Camera.js
index 068d7d7..172d667 100644
--- a/lib/common/plugin/Camera.js
+++ b/lib/common/plugin/Camera.js
@@ -52,9 +52,9 @@ cameraExport.getPicture = function(successCallback, errorCallback, options)
{
     var targetHeight = getValue(options.targetHeight, -1);
     var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG);
     var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE);
-    var allowEdit = getValue(options.allowEdit, 0) > 0;
-    var correctOrientation = getValue(options.correctOrientation, 0) > 0;
-    var saveToPhotoAlbum = getValue(options.saveToPhotoAlbum, 0) > 0;
+    var allowEdit = !!options.allowEdit;
+    var correctOrientation = !!options.correctOrientation;
+    var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
     var popoverOptions = getValue(options.popoverOptions, null);
 
     var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,


Mime
View raw message