Call preventDefault() on IDB errors so they don't bubble up to window.onerror

pull/165/head
Thibaut 10 years ago
parent 9b1d704e7c
commit 0231b84d5e

@ -37,7 +37,8 @@ class app.DB
db.close() db.close()
return return
onOpenError: => onOpenError: (event) =>
event?.preventDefault()
@useIndexedDB = @open = false @useIndexedDB = @open = false
@runCallbacks() @runCallbacks()
return return
@ -114,8 +115,13 @@ class app.DB
store = txn.objectStore('docs') store = txn.objectStore('docs')
req = store.get(doc.slug) req = store.get(doc.slug)
req.onsuccess = -> fn(req.result) req.onsuccess = ->
req.onerror = -> fn(false) fn(req.result)
return
req.onerror = (event) ->
event.preventDefault()
fn(false)
return
return return
return return
@ -140,8 +146,13 @@ class app.DB
docs.forEach (doc) -> docs.forEach (doc) ->
req = store.get(doc.slug) req = store.get(doc.slug)
req.onsuccess = -> result[doc.slug] = req.result req.onsuccess = ->
req.onerror = -> result[doc.slug] = false result[doc.slug] = req.result
return
req.onerror = (event) ->
event.preventDefault()
result[doc.slug] = false
return
return return
return return
@ -175,8 +186,13 @@ class app.DB
store = txn.objectStore(entry.doc.slug) store = txn.objectStore(entry.doc.slug)
req = store.get(entry.dbPath()) req = store.get(entry.dbPath())
req.onsuccess = -> if req.result then onSuccess(req.result) else onError() req.onsuccess = ->
req.onerror = onError if req.result then onSuccess(req.result) else onError()
return
req.onerror = (event) ->
event.preventDefault()
onError()
return
@loadDocsCache(db) unless @cachedDocs @loadDocsCache(db) unless @cachedDocs
return return
@ -192,6 +208,9 @@ class app.DB
@cachedDocs[cursor.key] = cursor.value @cachedDocs[cursor.key] = cursor.value
cursor.continue() cursor.continue()
return return
req.onerror = (event) ->
event.preventDefault()
return
return return
shouldLoadWithIDB: (entry) -> shouldLoadWithIDB: (entry) ->

Loading…
Cancel
Save