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 1ddcadb commit c2556f3
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
Expand Up @@ -259,6 +259,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() {
Expand All @@ -278,16 +286,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)
Expand Down

0 comments on commit c2556f3

Please sign in to comment.