Skip to content

Commit

Permalink
Only define arrayBuffer() if Blob is also supported
Browse files Browse the repository at this point in the history
It turns out that Android 4.0 implements ArrayBuffer but no Blob.

This restores the behavior that v1.0 had, but which regressed in v1.1.0.
  • Loading branch information
mislav committed Nov 17, 2016
1 parent 54ec096 commit 3d3bb0c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions fetch.js
Original file line number Diff line number Diff line change
@@ -251,6 +251,14 @@
return Promise.resolve(new Blob([this._bodyText]))
}
}

this.arrayBuffer = function() {
if (this._bodyArrayBuffer) {
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
} else {
return this.blob().then(readBlobAsArrayBuffer)
}
}
}

this.text = function() {
@@ -270,16 +278,6 @@
}
}

if (support.arrayBuffer) {
this.arrayBuffer = function() {
if (this._bodyArrayBuffer) {
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
} else {
return this.blob().then(readBlobAsArrayBuffer)
}
}
}

if (support.formData) {
this.formData = function() {
return this.text().then(decode)

0 comments on commit 3d3bb0c

Please sign in to comment.