Support polyfilling getAll with one tiny change
See original GitHub issueAlthough all modern browsers support getAll, old versions don’t. A while back I wrote indexeddb-getall-shim, and I’m still using it some places because I still have users on those old browsers.
Problem is, idb does not like my polyfill. Specifically it breaks on this line:
if (value instanceof IDBRequest)
I don’t think it is possible for me to create an actual IDBRequest, so instead I created a fake one. But I can’t make myFakeRequest instanceof IDBRequest
return true (well, I can by setting its prototype to IDBRequest, but it seems this results in browsers restricting what I can do with the object, making it useless for my purposes).
If instead your code was changed to:
if (value instanceof IDBRequest || (value && value.toString() === "[object IDBRequest]"))
then my polyfill would work fine.
Are you interested in adding this ugliness to your library? If so, I’m happy to make a PR.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:8 (5 by maintainers)
Hey there, @jakearchibald and @dumbmatter.
It’s nice to find this discussion here, because I’m actually a user of
idb
and the lack of support for Edge was a sad realization for us. In order to solve our app crashing on older Edge versions I actually implemented a polyfill based on @dumbmatter 's mentioned library.Just to contribute to the discussion, an
idb
pollyfill for thegetAll
method for unsupported browsers, or at least the tiny change that @dumbmatter suggested in their initial comment, would be very much desirable.Either way, thanks a lot to both of you for the work on these libraries.
Since the number of Edge users is decreasing, I’ve decided not to implement this. However, here’s a polyfill for anyone that needs it:
Demo: https://codesandbox.io/s/awesome-faraday-9q6bz?file=/src/index.ts
Plain JS version: