Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralise the checks for blob and form data support #78

Merged
merged 2 commits into from
Jan 24, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't sure about this because blobSupport actually checks a lot more than just 'Blob' in self

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