From d3f48bd8fd178f31d38bab94ac7f36e26e5a07be Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 4 Feb 2014 18:34:23 -0500 Subject: [PATCH] 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 --- src/ng/httpBackend.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ng/httpBackend.js b/src/ng/httpBackend.js index 11e1b999439c..efe72060facb 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);