So far as I can see, Section "3.1.3 Keys" doesn't seem to forbid circular
references in keys which are Array objects, but this will obviously cause
infinite loops in the comparison algorithm. This is in contrast to values,
where the structured clone algorithm explicitly deals with cyclic
references.
Example:
var circular_reference = [];
circular_reference.push(circular_reference); // directly cyclical
indexedDB.cmp(circular_reference, 0); // Expected behavior?
var circular_reference2 = [];
circular_reference2.push([circular_reference2]); // indirectly cyclical
indexedDB.cmp(circular_reference2, 0); // Expected behavior?
var circular_reference3 = [];
circular_reference3.push(circular_reference); // root is fine but child is
cyclical
indexedDB.cmp(circular_reference3, 0); // Expected behavior?
var circular_reference4 = [];
circular_reference4.non_numeric_property = circular_reference4;
indexedDB.cmp(circular_reference4, 0); // This should be fine, though.
I suggest an addition to the text e.g. "However, an Array values is only a
valid key if every item in the array is defined, if every item in the array
is a valid key (i.e. sparse arrays can not be valid keys), and if Array
value is not an item in the Array itself or any other Arrays within the
value. (i.e. arrays with cyclic references are not valid keys)." (That
could use a sprinkling of rigor, though.)