Skip to content

Commit

Permalink
Conditionally define Response#blob
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jan 5, 2015
1 parent 7e67f69 commit 8f61661
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,20 @@
throw new Error('Not implemented yet')
}

this.blob = function() {
var rejected = consumed(this)
return rejected ? rejected : Promise.resolve(new Blob([this._body]))
var blobSupport = (function() {
try {
new Blob();
return true
} catch(e) {
return false
}
})();

if (blobSupport) {
this.blob = function() {
var rejected = consumed(this)
return rejected ? rejected : Promise.resolve(new Blob([this._body]))
}
}

this.formData = function() {
Expand Down

0 comments on commit 8f61661

Please sign in to comment.