From 3d3bb0ca72172b224e8101c0a5264adc41f53929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 17 Nov 2016 16:57:35 +0100 Subject: [PATCH] Only define `arrayBuffer()` if Blob is also supported 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. --- fetch.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/fetch.js b/fetch.js index 3fb6c5fc..279373c7 100644 --- a/fetch.js +++ b/fetch.js @@ -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)