jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.4k stars 360 forks source link

`objectStoreNames`'s type seems wrong #101

Closed Ptival closed 3 years ago

Ptival commented 5 years ago

https://github.com/jakearchibald/idb/blob/809a75ccc31c46ac62174ff9c2c10efffa5a53df/lib/entry.ts#L149

As far as I can tell, within my browser, this method returns a DOMStringList, which is not an array.

In particular, it contains a method contains, and does not contain array methods such as indexOf, which leads to both static and run-time errors.

jakearchibald commented 5 years ago

Good point.

Ugh, fixing this isn't totally easy, as DOMStringList doesn't support types for its content.

(fwiw, in Edge, it does return an array, as this property is polyfilled. However I don't know how much I care about this difference, as I intend to remove EdgeHTML support in the next major version)

NotWoods commented 5 years ago

I'd be interested in submitted a PR for this if @jakearchibald hasn't worked on it yet 😄.

jakearchibald commented 5 years ago

Go for it!

shadow-light commented 3 years ago

I think there's still an issue with objectStoreNames when it is accessed off a transaction: https://github.com/jakearchibald/idb/blob/abce3c7c2fe4b3cfe4e1eb77f41ffaf0c79fd073/src/entry.ts#L531

It is array like, rather than DOMStringList. Just got burnt by this in a migration where I used includes instead of contains 😞

jakearchibald commented 3 years ago

I'll fix this tomorrow

jakearchibald commented 3 years ago

Fix published as 6.1.4.

shadow-light commented 3 years ago

Woohoo pipeline fixed, thanks!