Hi,
I think there is a mistmatch in the spec.
The context
The note here:
https://w3c.github.io/IndexedDB/#convert-a-value-to-a-key-range
"getAll() and getAllKeys() throw exceptions for Date, Array, and ArrayBuffer first arguments that return "invalid value" when used with convert a value to a key. For example, running getAll() with a NaN Date first argument throws an exception instead of successfully using an IDBGetAllOptions dictionary with default values."
I wasn't sure why this was a "Note" box and not explicitly written down in the spec, until I realized this probably comes from the following:
getAll/getAllKeys parameters handling is defined (since IDBGetAllOptions was introduced) by:
https://w3c.github.io/IndexedDB/#create-a-request-to-retrieve-multiple-items
"If running is a potentially valid key range with queryOrOptions is true, then:
And "is a potentially valid key range" is defined as:
https://w3c.github.io/IndexedDB/#is-a-potentially-valid-key-range
"If value is a key range, return true.
Let key be the result of converting a value to a key with value.
If key is "invalid type" return false.
Else return true."
Since converting a value to key will return "invalid value" for the cases mentioned in the note, and not "invalid type", #is-a-potentially-valid-key-range will return true, so step 8.1 from #create-a-request-to-retrieve-multiple-items will be run, resulting in an exception.
The issue
Right now in the #convert-a-value-to-a-key-range Note, Number is not listed, while it looks like it should be.
I don't think it makes a big difference since trying to convert NaN to a dictionnary (IDBGetAllOptions) will fail anyway, but it looks inconsistent, and the error returned will be different (TypeError instead of DOMException).
Hi,
I think there is a mistmatch in the spec.
The context
The note here:
https://w3c.github.io/IndexedDB/#convert-a-value-to-a-key-range
"getAll() and getAllKeys() throw exceptions for Date, Array, and ArrayBuffer first arguments that return "invalid value" when used with convert a value to a key. For example, running getAll() with a NaN Date first argument throws an exception instead of successfully using an IDBGetAllOptions dictionary with default values."
I wasn't sure why this was a "Note" box and not explicitly written down in the spec, until I realized this probably comes from the following:
getAll/getAllKeys parameters handling is defined (since IDBGetAllOptions was introduced) by:
https://w3c.github.io/IndexedDB/#create-a-request-to-retrieve-multiple-items
"If running is a potentially valid key range with queryOrOptions is true, then:
And "is a potentially valid key range" is defined as:
https://w3c.github.io/IndexedDB/#is-a-potentially-valid-key-range
"If value is a key range, return true.
Let key be the result of converting a value to a key with value.
If key is "invalid type" return false.
Else return true."
Since converting a value to key will return "invalid value" for the cases mentioned in the note, and not "invalid type", #is-a-potentially-valid-key-range will return true, so step 8.1 from #create-a-request-to-retrieve-multiple-items will be run, resulting in an exception.
The issue
Right now in the #convert-a-value-to-a-key-range Note, Number is not listed, while it looks like it should be.
I don't think it makes a big difference since trying to convert NaN to a dictionnary (IDBGetAllOptions) will fail anyway, but it looks inconsistent, and the error returned will be different (TypeError instead of DOMException).