dexie / Dexie.js

A Minimalistic Wrapper for IndexedDB
https://dexie.org
Apache License 2.0
11.69k stars 641 forks source link

v1.0.4 - TypeError: undefined is not an object (evaluating 'n.getDatabaseNames') inside iOS UIWebView #81

Closed aaron-schmidt closed 9 years ago

aaron-schmidt commented 9 years ago

Dexie v1.0.4

Error occurs the moment Dexie is instantiated: var dex = new Dexie('project-db');

Error occurs in: iOS WebView (UIWebView) Safari 5.1.7 on Windows 8.1: "TypeError: 'undefined' is not an object".

aaron-schmidt commented 9 years ago

Using non-minified Dexie.js:

message: "TypeError: undefined is not an object (evaluating 'indexedDB.getDatabaseNames')", line: 3152

aaron-schmidt commented 9 years ago

Potential fix for line 3152:

var fn = indexedDB && (indexedDB.getDatabaseNames || indexedDB.webkitGetDatabaseNames);
dfahlander commented 9 years ago

Thanks for reporting. It seems that the system you run it on does not have indexedDB at all. Could that be the case? If so, you would need to include the IndexedDBShim before including Dexie.js.

aaron-schmidt commented 9 years ago

Yes, neither iOS UIWebView nor Safari on Windows has an indexedDB object in the DOM. But in these cases (and others), I'd expect Dexie to fail silently not throw an exception. Our system is designed to fallback to using LocalStorage if IndexedDB does not exist. It should be a choice to include the IndexedDBShim versus a requirement.

dfahlander commented 9 years ago

Ok. I agree it would be better with at least a more explaining exception, and maybe a promise rejection when calling open.

aaron-schmidt commented 9 years ago

Sounds good to me. Appreciate the quick response.

hellectronic commented 9 years ago

I got an error with 1.0.4 too. Could not instatiate Dexie. The error does not occur when reverting back to 1.0.3 with bower.

dfahlander commented 9 years ago

Your suggestion made Dexie behave as before, namely to return a rejected Promise from db.open() and not throw TypeError on new Dexie().

Will be part of next release.