-
Notifications
You must be signed in to change notification settings - Fork 98
Description
I know this project has been taken over by @bramski (https://github.com/bramski/angular-indexedDB), but GitHub won't let me post an issue on that fork, so I'm posting it here instead.
Currently, the following lines are outside of the angular.module
definition, which means they run immediately when the file is loaded, rather than waiting for angular.bootstrap
to occur.
var IDBKeyRange, indexedDB,
__slice = [].slice;
indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
IDBKeyRange = window.IDBKeyRange || window.mozIDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange;
The problem is that if I'm running in a browser that doesn't natively support IndexedDB, and I'm loading a polyfill instead, then the above code will only work if the polyfill is loaded before the angular-indexed-db.js
file. But if the polyfill is being loaded dynamically (say, as an Angular module, a Require.js module, a Browserify package, or a Cordova plugin), then the polyfill won't load in time, and Angular-IndexedDB won't work.
To fix this problem, the four lines of code shown above just need to be moved inside of the angular.module
definition. That way, they won't run until all dynamically-loaded scripts are finished loading and angular.bootstrap
is called.