W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2009

Re: [widgets] Seeking comments on Last Call WD of Widgets: APIs and Events spec; deadline 15 Sept 2009

From: Marcos Caceres <marcosc@opera.com>
Date: Thu, 20 Aug 2009 12:49:17 +0200
Message-ID: <b21a10670908200349g534678e1h3abaec5f14c8772f@mail.gmail.com>
To: Scott Wilson <scott.bradley.wilson@gmail.com>
Cc: public-webapps WG <public-webapps@w3.org>
On Thu, Aug 20, 2009 at 11:46 AM, Scott
Wilson<scott.bradley.wilson@gmail.com> 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
Received on Thursday, 20 August 2009 10:50:20 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:33 GMT