[Pkg-javascript-commits] [dojo] 12/58: fixes #17117, handle falsy response.data in dojo/request/xhr

David Prévot taffit at moszumanska.debian.org
Thu Mar 24 04:28:24 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.10.5
in repository dojo.

commit e5253ecf87eafe43ad59e58110066118067b4812
Author: Benjamin Santalucia <ben at dojotoolkit-fr.org>
Date:   Mon Jun 1 04:51:51 2015 -0700

    fixes #17117, handle falsy response.data in dojo/request/xhr
---
 request/util.js                   |  2 +-
 tests/request/support/falsy.json  |  1 +
 tests/request/support/truthy.json |  1 +
 tests/request/xhr.html            | 27 ++++++++++++++++++++++++++-
 4 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/request/util.js b/request/util.js
index 86a9b42..7e28256 100644
--- a/request/util.js
+++ b/request/util.js
@@ -43,7 +43,7 @@ define([
 		return freeze(response);
 	}
 	function dataHandler (response) {
-		return response.data || response.text;
+		return response.data !== undefined ? response.data : response.text;
 	}
 
 	exports.deferred = function deferred(response, cancel, isValid, isReady, handleResponse, last){
diff --git a/tests/request/support/falsy.json b/tests/request/support/falsy.json
new file mode 100644
index 0000000..c508d53
--- /dev/null
+++ b/tests/request/support/falsy.json
@@ -0,0 +1 @@
+false
diff --git a/tests/request/support/truthy.json b/tests/request/support/truthy.json
new file mode 100644
index 0000000..27ba77d
--- /dev/null
+++ b/tests/request/support/truthy.json
@@ -0,0 +1 @@
+true
diff --git a/tests/request/xhr.html b/tests/request/xhr.html
index 5219949..199d9a2 100644
--- a/tests/request/xhr.html
+++ b/tests/request/xhr.html
@@ -52,6 +52,32 @@
 						);
 						return d;
 					},
+					function xhrGetJsonTruthyValue(t){
+						var d = new doh.Deferred();
+						var td = xhr.get(require.toUrl('./support/truthy.json'), {
+								preventCache: true,
+								handleAs: 'json'
+							}).then(
+								d.getTestCallback(function(response){
+									t.is(true, response);
+								})
+						);
+
+						return d;
+					},
+					function xhrGetJsonFalsyValue(t){
+						var d = new doh.Deferred();
+						var td = xhr.get(require.toUrl('./support/falsy.json'), {
+								preventCache: true,
+								handleAs: 'json'
+							}).then(
+								d.getTestCallback(function(response){
+									t.is(false, response);
+								})
+						);
+
+						return d;
+					},
 					function xhrGetQuery(t){
 						var d = new doh.Deferred();
 						var td = xhr.get("xhrDummyMethod.php?color=blue", {
@@ -408,4 +434,3 @@
 	<body>
 	</body>
 </html>
-

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list