Skip to content

Commit

Permalink
Centralise the checks for blob and form data support
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-andrews committed Jan 24, 2015
1 parent dac8035 commit 0ca546c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
return false
}
})();
var formDataSupport = 'FormData' in self;

function Body() {
this.bodyUsed = false
Expand All @@ -109,9 +110,9 @@
this._bodyInit = body
if (typeof body === 'string') {
this._bodyText = body
} else if ('Blob' in self && Blob.prototype.isPrototypeOf(body)) {
} else if (blobSupport && Blob.prototype.isPrototypeOf(body)) {
this._bodyBlob = body
} else if ('FormData' in self && FormData.prototype.isPrototypeOf(body)) {
} else if (formDataSupport && FormData.prototype.isPrototypeOf(body)) {
this._bodyFormData = body
} else if (!body) {
this._bodyText = ''
Expand Down Expand Up @@ -158,7 +159,7 @@
this._bodyInit = body
if (typeof body === 'string') {
this._bodyText = body
} else if ('FormData' in self && FormData.prototype.isPrototypeOf(body)) {
} else if (formDataSupport && FormData.prototype.isPrototypeOf(body)) {
this._bodyFormData = body
} else if (!body) {
this._bodyText = ''
Expand All @@ -173,7 +174,7 @@
}
}

if ('FormData' in self) {
if (formDataSupport) {
this.formData = function() {
return this.text().then(decode)
}
Expand Down

0 comments on commit 0ca546c

Please sign in to comment.