Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Dexie.js inside Chrome App #66

Closed
le0pard opened this issue Feb 22, 2015 · 5 comments
Closed

Using Dexie.js inside Chrome App #66

le0pard opened this issue Feb 22, 2015 · 5 comments

Comments

@le0pard
Copy link

le0pard commented Feb 22, 2015

Hello.

I am trying to use Dexie.js inside Chrome App. But inside Chrome app not available localStorage. In this case I get error about this: http://monosnap.com/image/E9hpQMgTXDgGzIpfVyecfJmExRZsYR

Does it possible to use Dexie without localStorage?

@dfahlander
Copy link
Collaborator

The reason localStorage is even used is to support Dexie.getDatabaseNames() for non-chromium browsers (Chrome and Opera has a native function to map to, but on other browsers we keep track of the global database list in a localStorage variable).

Due to lazy coding, localStorage were updated and managed also on chromium. Please use the latest version of src/Dexie.js instead which will not try to use localStorage where not needed.

dfahlander added a commit that referenced this issue Feb 22, 2015
@le0pard
Copy link
Author

le0pard commented Feb 23, 2015

Hello. Still have error in Chrome App, because it continue call window.localStorage on this line: https://github.com/dfahlander/Dexie.js/blob/master/src/Dexie.js#L3094

I checked, this can help:

Dexie.dependencies = {
  indexedDB: window._indexedDB || window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB,
  IDBKeyRange: window._IDBKeyRange || window.IDBKeyRange || window.webkitIDBKeyRange,
  IDBTransaction: window._IDBTransaction || window.IDBTransaction || window.webkitIDBTransaction,
  Error: window.Error || String,
  SyntaxError: window.SyntaxError || String,
  TypeError: window.TypeError || String,
  DOMError: window.DOMError || String,
  localStorage: ((typeof chrome !== "undefined" && chrome !== null ? chrome.storage : void 0) != null ? null : window.localStorage)
};

@dfahlander
Copy link
Collaborator

Thanks. Merged your suggestion in. Passes unit tests.
Please retest and verify it's a working solution and I'll close the issue.
Will be part of next release.

David

@le0pard
Copy link
Author

le0pard commented Feb 23, 2015

Thanks @dfahlander . All works.

@le0pard le0pard closed this as completed Feb 23, 2015
@dikaso
Copy link

dikaso commented Jun 30, 2015

Hello,

I have problem in xul application. It's calling window.localStorage which is not avaiable in xul.

If you don't need localStorage as a fallback, you can use this as a workaround:

// for dexie.js to work :(
        window.chrome = {
            storage: 'placeholder'
        };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants