From 99b8f2f167dd0b69c5e80e11018b64658bf5b1e7 Mon Sep 17 00:00:00 2001 From: yeonhoyoon Date: Wed, 16 Jul 2014 10:55:41 +0900 Subject: [PATCH] fix checking for FormData existence in Safari, typeof FormData returns "object" instead of "function" --- src/reqwest.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/reqwest.js b/src/reqwest.js index 00e39a8..91c817f 100644 --- a/src/reqwest.js +++ b/src/reqwest.js @@ -17,6 +17,7 @@ , lastValue // data stored by the most recent JSONP callback , xmlHttpRequest = 'XMLHttpRequest' , xDomainRequest = 'XDomainRequest' + , isFormDataSupported = typeof FormData === "function" || typeof FormData === "object" , noop = function () {} , isArray = typeof Array.isArray == 'function' @@ -83,7 +84,7 @@ || defaultHeaders['accept'][o['type']] || defaultHeaders['accept']['*'] - var isAFormData = typeof FormData === "function" && (o['data'] instanceof FormData); + var isAFormData = isFormDataSupported && (o['data'] instanceof FormData); // breaks cross-origin requests with legacy browsers if (!o['crossOrigin'] && !headers[requestedWith]) headers[requestedWith] = defaultHeaders['requestedWith'] if (!headers[contentType] && !isAFormData) headers[contentType] = o['contentType'] || defaultHeaders['contentType']