axemclion / jquery-indexeddb

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

TypeError related to IDBCursor.PREV #43

Open lovett opened 11 years ago

lovett commented 11 years ago

There's a minor flaw with the IndexedDB object detection logic. IDBCursor is set to either window.IDBCursor or window.webkitIDBCursor, but if neither of these exist there is no fallback. That's not so bad by itself, but it means the subsequent attempt to set IDBCursor.PREV and IDBCursor.NEXT may throw a type error because they are setting a property on an undefined value.

I ran across this in an application that bundles jquery.indexeddb.js into a larger file that concatenates several libraries. This causes clients that don't support IndexedDB to receive this file even though they don't otherwise invoke it. The ones without support throw the type error because they still perform the object detection.

This could be fixed by setting IDBCursor to a an empty object if nothing more suitable is available. Or alternately by not setting prev and next if IDBCursor is undefined.

axemclion commented 11 years ago

This is a good suggestion. @lovett, can you please send a pull request for this to the incoming-pr branch ?