Skip to content
Browse files

Define in-line constants for transaction types

  • Loading branch information...
1 parent a99108a commit 99af9a1ba6092af14fa5cbeefba5a349940e5e4b @krestenkrab committed
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/adapters/indexed-db.js
View
10 src/adapters/indexed-db.js
@@ -13,7 +13,9 @@ Lawnchair.adapter('indexed-db', (function(){
return window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.oIndexedDB || window.msIndexedDB;
};
-
+ var READ_ONLY = 0;
+ var READ_WRITE = 1;
+ var VERSION_CHANGE = 2;
return {
@@ -68,7 +70,7 @@ Lawnchair.adapter('indexed-db', (function(){
var self = this;
var win = function (e) { if (callback) { obj.key = e.target.result; self.lambda(callback).call(self, obj) }};
- var trans = this.db.transaction(["teststore"], webkitIDBTransaction.READ_WRITE, 0);
+ var trans = this.db.transaction(["teststore"], READ_WRITE, 0);
var store = trans.objectStore("teststore");
var request = obj.key ? store.put(obj, obj.key) : store.put(obj);
@@ -87,7 +89,7 @@ Lawnchair.adapter('indexed-db', (function(){
var updateProgress = function(obj) {
results.push(obj)
- done = results.length === objs.length
+ done = (results.length === objs.length)
}
var checkProgress = setInterval(function() {
@@ -233,7 +235,7 @@ Lawnchair.adapter('indexed-db', (function(){
try {
this.db
- .transaction(["teststore"], webkitIDBTransaction.READ_WRITE)
+ .transaction(["teststore"], READ_WRITE)
.objectStore("teststore").clear().onsuccess = win;
} catch(e) {

1 comment on commit 99af9a1

@ebidel

If those constant values change in the future, you're toast. You probably want to do something more like:

if ('webkitIndexedDB' in window) {
window.IDBTransaction = window.webkitIDBTransaction;
window.IDBKeyRange = window.webkitIDBKeyRange;
}

to handle the webkit prefixes

Please sign in to comment.
Something went wrong with that request. Please try again.