indexeddbshim / IndexedDBShim

A polyfill for IndexedDB using WebSql
Other
968 stars 191 forks source link

Weird Safari #271

Closed neville9763 closed 7 years ago

neville9763 commented 8 years ago

Hi

I am using the shim and Dexie (https://github.com/dfahlander/Dexie.js) and having an issue with mobile Safari (ios 9.3.5), and have implemented the following code as suggested (on Dexie site):

    //add db shim for ios
    if(/(iPhone|iPod|iPad)/i.test(navigator.userAgent)) { 

        // Force shim
        //window.shimIndexedDB.__debug(true);
        window.shimIndexedDB.__useShim();

        Dexie.dependencies.indexedDB = window.shimIndexedDB;
        Dexie.dependencies.IDBKeyRange = window.shimIndexedDB.modules.IDBKeyRange;

    } else {

        // Force native
        Dexie.dependencies.indexedDB = indexedDB;
        Dexie.dependencies.IDBKeyRange = IDBKeyRange;

    }

When forcing use of the shim (using __useShim), the object shimIndexedDB is created as expected but shimIndexedDB.modules.IDBKeyRange remains undefined (also window.shimIndexedDB.modules.IDBKeyRange and self.shimIndexedDB.modules.IDBKeyRange are also undefined).

On other platforms, no issues.

Anybody have any suggestions about how I can try and resolve this or where I can find IDBKeyRange?

Thanks

Neville

pesimeao commented 7 years ago

Any update on this?

brettz9 commented 7 years ago

I am working as I can on getting IndexedDBShim to pass a number of tests in its core functionality before testing browser specific bugs for an anticipated 3.0.0 release. You are welcome to try the code in master and see how it meets your needs as well as update the issue or submit a PR.

IDBKeyRange is defined in src/IDBKeyRange.js. If you experiment with the code, you will need to run the build steps and include the relevant updated file in dist. We'd love to have more concrete information on exactly how and why it is failing in Safari, but I don't expect having time to look at it more closely for some time as I work through some other bugs while testing on the more stable platforms of Node and Chrome.

brettz9 commented 7 years ago

Ok, in now finally being able to pay a little attention to browser-specific issues...

In master, the standard IDB modules are no longer being set on window.shimIndexedDB.modules. Just look on window.IDBKeyRange once __useShim() has been called.

I will close as that should answer your question, but feel free and comment further or reopen if there is something else.

brettz9 commented 7 years ago

Btw, you may want to watch #277 (to which I intend to add a comment shortly) as it is of concern for iOS9 (and non-Chrome Android).