[Pkg-javascript-commits] [dojo] 10/149: Add Blob support for Safari <7
David Prévot
taffit at moszumanska.debian.org
Sat Feb 27 03:13:42 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 fb7a76cb0a1dd85463dc419d0814d8c8b9877125
Author: Colin Snover <github.com at zetafleet.com>
Date: Thu Aug 14 02:05:54 2014 +0000
Add Blob support for Safari <7
Fixes #18218.
---
request/handlers.js | 4 ++++
request/xhr.js | 19 +++++++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/request/handlers.js b/request/handlers.js
index 59b7d86..5cd4e20 100644
--- a/request/handlers.js
+++ b/request/handlers.js
@@ -62,6 +62,10 @@ define([
}
var handleNativeResponse = function(response) {
+ if(!has('native-xhr2-blob') && response.options.handleAs === 'blob' && typeof Blob !== 'undefined'){
+ return new Blob([ response.xhr.response ], { type: response.xhr.getResponseHeader('Content-Type') });
+ }
+
return response.xhr.response;
}
diff --git a/request/xhr.js b/request/xhr.js
index 247747d..fff0b54 100644
--- a/request/xhr.js
+++ b/request/xhr.js
@@ -31,9 +31,24 @@ define([
return has('native-xhr') && typeof new XMLHttpRequest().responseType !== 'undefined';
});
+ has.add('native-xhr2-blob', function(){
+ if(!has('native-response-type')){ return; }
+ var x = new XMLHttpRequest();
+ x.open('GET', '/', true);
+ x.responseType = 'blob';
+ // will not be set if unsupported
+ var responseType = x.responseType;
+ x.abort();
+ return responseType === 'blob';
+ });
+
// Google Chrome doesn't support "json" response type
// up to version 30, so it's intentionally not included here
- var nativeResponseTypes = {'blob': 1, 'document': 1, 'arraybuffer': 1};
+ var nativeResponseTypes = {
+ 'blob': has('native-xhr2-blob') ? 'blob' : 'arraybuffer',
+ 'document': 'document',
+ 'arraybuffer': 'arraybuffer'
+ };
function handleResponse(response, error){
var _xhr = response.xhr;
@@ -197,7 +212,7 @@ define([
}
if(has('native-response-type') && options.handleAs in nativeResponseTypes) {
- _xhr.responseType = options.handleAs;
+ _xhr.responseType = nativeResponseTypes[options.handleAs];
}
var headers = options.headers,
--
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