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

[whatwg] Storage Events for a Specific Storage Area

From: Ian Hickson <ian@hixie.ch>
Date: Mon, 13 Jul 2009 10:10:52 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0907130933160.23663@hixie.dreamhostps.com>
On Wed, 17 Jun 2009, Joseph Pecoraro wrote:
>
> The "storage" event [1] fires for both sessionStorage and localStorage.  
> To me, this means if you only want to interact with localStorage you 
> will have to manually ensure that it is the storage area being modified:
> 
>   window.addEventListener('storage', function(e) {
>     if ( e.storageArea === localStorage ) {
>       // ...
>     }
>   }
> 
> Was there any discussion about creating events specific to the storage 
> object, or should that already be possible?  I've been playing around 
> with WebKit's Storage implementation, and the following (understandably) 
> is not possible:
> 
>   > localStorage.addEventListener
>   undefined
> 
> Is there any way to listen to events for a single specific storage area 
> or is the previously mentioned approach preferred?

We could make Storage into an EventTarget and also fire events on there, 
sure. As Jeremy said, this is something that might best be done in the 
next version; we're still trying to get the current features implemented 
in a stable and consistent fashion as it is.

In general, though, I don't think it's critical, since you can easily work 
around it by checking which was changed based on the event data.

(I agree that your proposal would have made more sense. I'm sorry my 
learning experiences have such a detrimental effect on the Web! :-) )

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 13 July 2009 03:10:52 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:14 UTC