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

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


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

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

commit 3e2acc24702ea82276a34847fe65efa632e02e81
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
    
    (cherry picked from commit e5253ecf87eafe43ad59e58110066118067b4812)
---
 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 5b486bf..4d03d64 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", {
@@ -317,4 +343,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