aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaitlin Potter2014-02-04 18:34:23 -0500
committerCaitlin Potter2014-02-04 19:34:31 -0500
commit24699ee8f04c1f1459be1d36207e654421d58ff0 (patch)
tree1635725a1671a8385158fe56ef75742aa34782cc
parentaa6a0e3fc6e98e362b5705ea730ab9c2fcf7a7e6 (diff)
downloadangular.js-24699ee8f04c1f1459be1d36207e654421d58ff0.tar.bz2
fix($http): ignore xhr.responseType setter exception if value is "json"
WebKit added support for the json responseType value on 09/03/2013 https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are known to throw when setting the value "json" as the response type. Other older browsers implementing the responseType. Other browsers with infrequent update cycles may also be affected. The json responseType value can be ignored if not supported, because JSON payloads are parsed on the client-side regardless. Closes #6115 Closes #6122
-rw-r--r--src/ng/httpBackend.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/ng/httpBackend.js b/src/ng/httpBackend.js
index 11e1b999..efe72060 100644
--- a/src/ng/httpBackend.js
+++ b/src/ng/httpBackend.js
@@ -107,7 +107,20 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
}
if (responseType) {
- xhr.responseType = responseType;
+ try {
+ xhr.responseType = responseType;
+ } catch (e) {
+ // WebKit added support for the json responseType value on 09/03/2013
+ // https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are
+ // known to throw when setting the value "json" as the response type. Other older
+ // browsers implementing the responseType
+ //
+ // The json response type can be ignored if not supported, because JSON payloads are
+ // parsed on the client-side regardless.
+ if (responseType !== 'json') {
+ throw e;
+ }
+ }
}
xhr.send(post || null);