The question is important as it affects conformance. Currently we only support the first of the three methods you've stated, and there was discussion on the list previously as to whether the second of the three was even possible in a pure JavaScript implementation (search for "syntactic sugar").

What is the actual conformance requirement?

S

On 20 Aug 2009, at 11:49, Marcos Caceres wrote:

On Thu, Aug 20, 2009 at 11:46 AM, Scott
Wilson<[email protected]> wrote:
The Storage [1 interface ] is defined as:

interface Storage {
 readonly attribute unsigned long length;
 getter any key(in unsigned long index);
 getter any getItem(in DOMString key);
 setter creator void setItem(in DOMString key, in any data);
 deleter void removeItem(in DOMString key);
 void clear();
};

I don't see any mention of accessing Storage as an array in either
WebStorage or Widgets A&E.
S


Storage is just a javascript object, so it's properties can be
accessed any multiple ways:

preferences.getItem(theNameOfTheKey);
preferences.theNameOfTheKey
preferences[preferences[0]]

This makes the object that implements the interface tremendously
powerful and flexible. However, I agree that WebStorage should make
this more clear; but that should probably go into a primer, not in the
spec.

Try it out in Firefox's address bar:
javascript: localStorage.setItem("test", "test123");
javascript: alert(localStorage[localStorage[0]])
javascript: alert(localStorage.test)

The above will alert you "test123"

--
Marcos Caceres
http://datadriven.com.au

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to