summaryrefslogtreecommitdiff
path: root/www/lib/localforage/src/utils/isIndexedDBValid.js
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2017-09-27 11:39:30 -0400
committerPliable Pixels <pliablepixels@gmail.com>2017-09-27 11:39:30 -0400
commite18708f10b04455be151a5a799f0109c34f20a25 (patch)
tree9e4559ef0fff8b366474e7768308ddca1e32268a /www/lib/localforage/src/utils/isIndexedDBValid.js
parent97a1cb3ae199c7b5455dcba0001efd5b4c32040a (diff)
package updates to set up bower correctly #535
Diffstat (limited to 'www/lib/localforage/src/utils/isIndexedDBValid.js')
-rw-r--r--www/lib/localforage/src/utils/isIndexedDBValid.js33
1 files changed, 15 insertions, 18 deletions
diff --git a/www/lib/localforage/src/utils/isIndexedDBValid.js b/www/lib/localforage/src/utils/isIndexedDBValid.js
index aa14b6d8..f8150875 100644
--- a/www/lib/localforage/src/utils/isIndexedDBValid.js
+++ b/www/lib/localforage/src/utils/isIndexedDBValid.js
@@ -7,28 +7,25 @@ function isIndexedDBValid() {
if (!idb) {
return false;
}
- // We mimic PouchDB here; just UA test for Safari (which, as of
- // iOS 8/Yosemite, doesn't properly support IndexedDB).
- // IndexedDB support is broken and different from Blink's.
- // This is faster than the test case (and it's sync), so we just
- // do this. *SIGH*
- // http://bl.ocks.org/nolanlawson/raw/c83e9039edf2278047e9/
+ // We mimic PouchDB here;
//
// We test for openDatabase because IE Mobile identifies itself
// as Safari. Oh the lulz...
- if (typeof openDatabase !== 'undefined' && typeof navigator !== 'undefined' &&
- navigator.userAgent &&
- /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)) {
- return false;
- }
+ var isSafari = typeof openDatabase !== 'undefined' &&
+ /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) &&
+ !/Chrome/.test(navigator.userAgent) &&
+ !/BlackBerry/.test(navigator.platform);
+
+ var hasFetch = typeof fetch === 'function' &&
+ fetch.toString().indexOf('[native code') !== -1;
- return idb &&
- typeof idb.open === 'function' &&
- // Some Samsung/HTC Android 4.0-4.3 devices
- // have older IndexedDB specs; if this isn't available
- // their IndexedDB is too old for us to use.
- // (Replaces the onupgradeneeded test.)
- typeof IDBKeyRange !== 'undefined';
+ // Safari <10.1 does not meet our requirements for IDB support (#5572)
+ // since Safari 10.1 shipped with fetch, we can use that to detect it
+ return (!isSafari || hasFetch) &&
+ typeof indexedDB !== 'undefined' &&
+ // some outdated implementations of IDB that appear on Samsung
+ // and HTC Android devices <4.4 are missing IDBKeyRange
+ typeof IDBKeyRange !== 'undefined';
} catch (e) {
return false;
}