-
Notifications
You must be signed in to change notification settings - Fork 70
Description
I am reporting a possible error in the 28 February 2025 draft of the Indexed Database API 3.0.
This is a quote from Example 6, regarding the behavior of in-line keys and key generators:
Attempting to store a property on a primitive value will fail and throw an error. In the first example below the key path for the object store is "foo". The actual object is a primitive with the value, 4. Trying to define a property on that primitive value fails. The same is true for arrays. Properties are not allowed on an array. In the second example below, the actual object is an array, [10]. Trying to define a property on the array fails.
const store = db.createObjectStore("store", { keyPath: "foo", autoIncrement: true }); // The key generation will attempt to create and store the key path // property on this primitive. store.put(4); // will throw DataError // The key generation will attempt to create and store the key path // property on this array. store.put([10]); // will throw DataError
When I test this behavior with recent releases of Chrome and Firefox, I observe that store.put(4) throws DataError as specified, but store.put([10]) does not.
I think that the implementations are correct, and the specification is wrong. The following statement
The same is true for arrays. Properties are not allowed on an array.
in the specification is not true, as one can demonstrate in the browser's JavaScript console:
let array = [10]; // undefined
typeof array; //"object"
array['foo'] = 1; // 1
array['foo']; // 1