Open shadow-light opened 2 years ago
This is a good point.
I think FakeDOMStringList does need to subclass/extend the built-in Array, because otherwise I don't know how you'd get various proper behaviors like destructuring. Please correct me if I'm wrong.
But it should either delete the Array-specific methods from the class or if that's not possible manually override them to throw errors. I think that should be possible, at least.
I was planning on doing a new release soon, I will try to include this.
That sounds good, thanks for looking into it
Turns out the solution I came up with in 7879a2459cc287d46076ec124a635c004ed55413 causes some problems when used with Dexie. I'm not sure why. But I guess it'll be safer to not do this, unless someone can help me figure out a better way.
[].slice.call(arrayLike)
is the problem, that is supposed to turn a DOMStringList into an array, but was not actually restoring the deleted methods.
FakeDOMStringList seems to be extending array, but a number of array methods aren't available. Such that tests can pass and then result in failure in production.
I had a migration that executed
transaction.objectStoreNames.includes('...')
and didn't cause any issues, but then failed in production as should have beentransaction.objectStoreNames.contains('...')
. Didn't pick up on it with types due to a bug in idb