axemclion / jquery-indexeddb

An IndexedDB Plugin for Jquery.
Other
195 stars 70 forks source link

Numeric transaction modes are deprecated in IDBDatabase.transaction #25

Closed djQuery closed 11 years ago

djQuery commented 11 years ago

Numeric transaction modes are deprecated in IDBDatabase.transaction. Use "readonly" or "readwrite".

I keep seeing these errors in the console. This happens on the demo on your site as well. http://nparashuram.com/jquery-indexeddb/example/index.html

docslax commented 11 years ago

It should be warnings, not errors. While numeric transactions are deprecated they have not been removed completely yet.. we'll at least in Chrome they haven't as of the latest build. I'm not 100% sure about Firefox's latest or IE at all.

The fix is easy enough however, but since I'm not sure how long before the Dev fixes it I'll post it here..

If you are using jquery.indexeddb.js just replace the getDefaultTransaction function with this one.

function getDefaultTransaction(mode){
    var result = null;
    switch (mode) {
        case 0:
        case "readwrite":
            result = "readwrite";
            break;
        case 1:
        case "readonly":
            result = "readonly";
            break;
        default:
            result = "readwrite";
    }
    return result;
}

If you are using jquery.indexeddb.min.js my suggestion is to beautify the code then update the above function and re-minify.

ChristophGr commented 11 years ago

Keep in mind that Firefox 10 ESR does not support the string-style, so there should be something like

if (window.indexedDB) { // use string-style } else { // use deprecated constants }

axemclion commented 11 years ago

With commit # 506776f, only supported modes are used. Keeping modes as 0 and 1 so that code written before this also works.