Closed forresto closed 9 years ago
This commit makes the shim work for Safari 7.1 and 8.0+: https://github.com/noflo/noflo-indexeddb/commit/89079ad7a57f92397b42456908ee56a8fa36b4b6
It isn't 100% compatible, because this library shims more than we use, and does it by setting window.indexedDB, which you can't do in the Safari releases with broken indexedDB. So I'm using
var idb = window.overrideIndexedDB || window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
I can make a proper pull request if there is interest, but it isn't really a shim if you have to check for overrideIndexedDB
.
Safari tracking for the bug: https://bugs.webkit.org/show_bug.cgi?id=136888#c5 More info: http://pouchdb.com/2014/09/22/3.0.6.html
Yes, you can force the shim to override the native IndexedDB implementation by calling window.shimIndexedDB.__useShim()
. However, due to a WebKit bug, the window.indexedDB
variable is read-only, so we can't shim it. Until WebKit fixes the bug, there are two possible workarounds that you can use:
window.shimIndexedDB
instead of window.indexedDB
We always add this property to the window object, even if the browser natively supports IndexedDB. This allows you to use the shim instead of the native implementation, which is useful because some native implementations are really buggy (Safari and IE).indexedDB
variable in your closure
By creating a variable named indexedDB
, all the code within that closure will use the variable instead of the window.indexedDB
property. For example:(function() {
// This works on all browsers, and only uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB ||
window.mozIndexedDB ||
window.webkitIndexedDB ||
window.msIndexedDB ||
window.shimIndexedDB;
// This code will use the native IndexedDB, if it exists, or the shim
indexedDB.open("MyDatabase", 1);
})();
Safari implemented a broken IndexedDB in 7.1. Would it be possible to force the shim in 7.1 as well as 8 #167?
The shim works in Safari <=7.0 :+1:
Should add Safari 7.1 and 8 to the saucelabs test.