javascript - UnknownError in Safari 7.1 when creating multiple object stores with IndexedDB -
javascript - UnknownError in Safari 7.1 when creating multiple object stores with IndexedDB -
i wanted sanity check , see if else having problem safari 7.1 , indexeddb. seems error of type unknownerror, which, according spec @ http://www.w3.org/tr/indexeddb/ occurs when "the operation failed reasons unrelated database , not covered other errors." occurs sec time phone call function, after first phone call has called callbacks (either onsuccess or onerror). here function creating object store, works in both chrome , firefox.
indexeddbclient.prototype.createobjectstore = function(options) { if (this.checkifobjectstoreexists(options.objectstorename)) { options.onerror(this.objectstorednemessage); return; } var objectstore; var objectstorecreated = false; var databaseopened = false; var version = this.database.version; var dbname = this.database.name; this.database.close(); var request = indexeddb.open(dbname, ++version); var = this; request.onupgradeneeded = function(e) { that.database = e.target.result; objectstore = that.database.createobjectstore(options.objectstorename, { keypath: options.keypathname }); objectstore.transaction.oncomplete = function(e) { objectstorecreated = true; successcallback(); } objectstore.transaction.onerror = function(e) { options.onerror(e); }; }; request.onsuccess = function(e) { databaseopened = true; successcallback(); } request.onerror = function(e) { options.onerror(e); }; request.onblocked = function(e) { typeof options.onblocked === 'function' && options.onblocked(); }; function successcallback() { // needed because must sure both objectstore creation transaction has completed, // , db open request has fired onsuccess event. objectstorecreated && databaseopened && options.onsuccess(objectstore); } };
indexeddb api in safari browser has bug on multiple stores transaction.
javascript safari indexeddb
Comments
Post a Comment