W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2011

[IndexedDB] Array keys / circular references

From: Joshua Bell <jsbell@chromium.org>
Date: Tue, 1 Nov 2011 09:24:07 -0700
Message-ID: <CAD649j6h9+N-WozTXrb5O1jjGQZsjFDrCSpTA7euzvDEqPgySg@mail.gmail.com>
To: public-webapps@w3.org
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


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
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.)
Received on Tuesday, 1 November 2011 16:24:43 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:36 UTC