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

David Prévot taffit at moszumanska.debian.org
Sat Feb 27 03:13:48 UTC 2016


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

taffit pushed a commit to branch master
in repository dojo.

commit db66e918cd5a736fa4023741ace82e1bdc0fb612
Author: Benjamin Santalucia <ben at dojotoolkit-fr.org>
Date:   Fri May 29 15:12:15 2015 -0700

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

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/unit/request/support/falsy.json b/tests/unit/request/support/falsy.json
new file mode 100644
index 0000000..02e4a84
--- /dev/null
+++ b/tests/unit/request/support/falsy.json
@@ -0,0 +1 @@
+false
\ No newline at end of file
diff --git a/tests/unit/request/support/truthy.json b/tests/unit/request/support/truthy.json
new file mode 100644
index 0000000..f32a580
--- /dev/null
+++ b/tests/unit/request/support/truthy.json
@@ -0,0 +1 @@
+true
\ No newline at end of file
diff --git a/tests/unit/request/xhr.js b/tests/unit/request/xhr.js
index 1e896d1..0a15d10 100644
--- a/tests/unit/request/xhr.js
+++ b/tests/unit/request/xhr.js
@@ -48,6 +48,33 @@ define([
 				})
 			);
 		},
+		
+		'.get json with truthy value': function () {
+			var def = this.async(),
+				promise = xhr.get(require.toUrl('./support/truthy.json'), {
+					preventCache: true,
+					handleAs: 'json'
+				});
+
+			promise.then(
+				def.callback(function (response) {
+					assert.strictEqual(response, true);
+				})
+			);
+		},
+		'.get json with falsy value': function () {
+			var def = this.async(),
+				promise = xhr.get(require.toUrl('./support/falsy.json'), {
+					preventCache: true,
+					handleAs: 'json'
+				});
+
+			promise.then(
+				def.callback(function (response) {
+					assert.strictEqual(response, false);
+				})
+			);
+		},
 
 		'.get with query': function () {
 			var def = this.async(),

-- 
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