History

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

Thibaut committed 11 years ago

Commit 0231b841 parent 9b1d7041 file · +26 −7Browse files

Unified · Split

assets/javascripts/app/db.coffee+26−7
@@ -37,7 +37,8 @@ class app.DB · 36 unmodified lines
37 db.close()37 db.close()
38 return38 return
39 39
40 onOpenError: =>40 onOpenError: (event) =>
41 event?.preventDefault()
41 @useIndexedDB = @open = false42 @useIndexedDB = @open = false
42 @runCallbacks()43 @runCallbacks()
43 return44 return
@@ -114,8 +115,13 @@ class app.DB · 70 unmodified lines
114 store = txn.objectStore('docs')115 store = txn.objectStore('docs')
115 116
116 req = store.get(doc.slug)117 req = store.get(doc.slug)
117 req.onsuccess = -> fn(req.result)118 req.onsuccess = ->
118 req.onerror = -> fn(false)119 fn(req.result)
120 return
121 req.onerror = (event) ->
122 event.preventDefault()
123 fn(false)
124 return
119 return125 return
120 return126 return
121 127
@@ -140,8 +146,13 @@ class app.DB · 18 unmodified lines
140 146
141 docs.forEach (doc) ->147 docs.forEach (doc) ->
142 req = store.get(doc.slug)148 req = store.get(doc.slug)
143 req.onsuccess = -> result[doc.slug] = req.result149 req.onsuccess = ->
144 req.onerror = -> result[doc.slug] = false150 result[doc.slug] = req.result
151 return
152 req.onerror = (event) ->
153 event.preventDefault()
154 result[doc.slug] = false
155 return
145 return156 return
146 return157 return
147 158
@@ -175,8 +186,13 @@ class app.DB · 27 unmodified lines
175 store = txn.objectStore(entry.doc.slug)186 store = txn.objectStore(entry.doc.slug)
176 187
177 req = store.get(entry.dbPath())188 req = store.get(entry.dbPath())
178 req.onsuccess = -> if req.result then onSuccess(req.result) else onError()189 req.onsuccess = ->
179 req.onerror = onError190 if req.result then onSuccess(req.result) else onError()
191 return
192 req.onerror = (event) ->
193 event.preventDefault()
194 onError()
195 return
180 @loadDocsCache(db) unless @cachedDocs196 @loadDocsCache(db) unless @cachedDocs
181 return197 return
182 198
@@ -192,6 +208,9 @@ class app.DB · 9 unmodified lines
192 @cachedDocs[cursor.key] = cursor.value208 @cachedDocs[cursor.key] = cursor.value
193 cursor.continue()209 cursor.continue()
194 return210 return
211 req.onerror = (event) ->
212 event.preventDefault()
213 return
195 return214 return
196 215
197 shouldLoadWithIDB: (entry) ->216 shouldLoadWithIDB: (entry) ->