[Web Storage] A couple questions about the storage spec

Hello all,

I have a couple questions about the storage spec (I'm reading the June 15th version at (http://dev.w3.org/html5/webstorage/). 

(1) The spec says:
"The object's indices of the supported indexed properties are the numbers in the range zero to one less than the number of key/value pairs currently present in the list associated with the object. If the list is empty, then there are no supported indexed properties."

As far as I can tell, this seems to say I should be able to say something like:
	window.localStorage[3]
and get something back (not clear if the key or the value).  Am I right in my interpretation of that paragraph?
I saw some discussion earlier about whether something like localStorage[3] was meaningful, but I didn't find the resolution.  It does seem undesirable/confusing to me.  And none of the browsers I've tried this with do this.  So, I'm just confused, and probably misunderstanding "indices of the supported indexed properties".  Thanks for any clarification.


(2) The spec also says:
"The names of the supported named properties on a Storage object are the keys of each key/value pair currently present in the list associated with the object."
I read that (possibly/probably wrongly) as saying I should be able to say
	window.localStorage.setItem("foo", "bar");
	myVariable = window.localStorage["foo"];
and now myVariable will have "bar".

If my reading is right (and it is the behavior I see in a couple browsers) this makes me very nervous, because I can do something like:
	window.localStorage.setItem("length", "a value we computer");
	window.localStorage.setItem("clear", "something that is transparent");
which of course allows:
	window.localStorage["length"];
	window.localStorage["clear"];
but in the browsers I've looked at, this (of course) also kinda messes up things like:
	for (index = 0; index < window.localStorage.length; index++) {
		// whatever
	}
	window.localStorage.clear();
since length is now not a number, and clear isn't a function.

Why is this a desirable feature?


(3) Real nitpicking here:
The IDL for the Storage interface says
  setter creator void setItem(in DOMString key, in any data);
but the text says
	The setItem(key, value) method
Note the name of the second parameter is different between these.


Thank you.  Despite my nitpicking above, I really appreciate the presence of this spec! :-)


david

p.s. I'm still coming up to speed on these specs, so if I'm just misunderstanding something basic, direct me to TFM that I should R. 

Received on Friday, 9 July 2010 12:52:19 UTC