W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2009

[whatwg] localStorage feedback

From: Brett Cannon <brett@python.org>
Date: Tue, 13 Oct 2009 20:32:12 -0700
Message-ID: <bbaeab100910132032l3215f158g12635401e14d425b@mail.gmail.com>
Found how to subscribe to the webapps list. Turns out I was trying to join
the working group and not the mailing list.

On Tue, Oct 13, 2009 at 16:28, Ian Hickson <ian at hixie.ch> wrote:

> On Tue, 13 Oct 2009, Jeremy Orlow wrote:
> > On Tue, Oct 13, 2009 at 3:40 PM, Ian Hickson <ian at hixie.ch> wrote:
> > > On Tue, 13 Oct 2009, Brett Cannon wrote:
> > > > On Mon, Oct 12, 2009 at 19:07, Ian Hickson <ian at hixie.ch> wrote:
> > > > >
> > > > > I believe you can test if a key is in the storage area using:
> > > > >
> > > > >   if (key in storage) { ... }
> > > > >
> > > > > For example:
> > > > >
> > > > >   if ('document' in window.localStorage) { ... }
> > > >
> > > > I didn't find that in the spec anywhere. Is it somehow implicit and I
> > > > just missed it? Or will it be specified sometime in the future?
> > >
> > > It's the net effect of this line in the spec:
> > >
> > > # 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.
> > >
> > > ...combined with the definitions in the WebIDL spec.
> >
> > It seems odd that there wouldn't be a corresponding method on
> > localStorage given that the deleter, getter, and setter all have them.
>
> Personally I'd rather remove those methods, but I think we're stuck with
> them at this point.


While usability does go up when you use things like setting keys/values
directly off of localStorage instead of using setItem(), etc. it does make
it much more difficult to provide a drop-in library to provide enhanced
features and fix compatibility issues thanks to JavaScript not supporting
thorough operator overloading. For instance, IE 8 doesn't provide a way to
do an equivalent 'length' attribute (until ECMAScript 5 is supported). And I
have no clue how to potentially fix any browser incompatibility that the
'in' operator might introduce.

And taking away the functions would force people like me to come up with
their own API instead of using the defined functions. Providing functions
mirroring things you can do directly with an object might be a pain, but it
does help overcome a shortcoming of JavaScript.

-Brett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20091013/8f3866a2/attachment.htm>
Received on Tuesday, 13 October 2009 20:32:12 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:53 UTC