- From: Jonas Sicking <jonas@sicking.cc>
- Date: Thu, 28 Jan 2010 15:52:35 -0800
- To: Olli@pettay.fi
- Cc: Jared Morse <jarcoal@gmail.com>, public-webapps@w3.org
On Thu, Jan 28, 2010 at 3:38 PM, Olli Pettay <Olli.Pettay@helsinki.fi> wrote:
> On 1/29/10 12:22 AM, Jared Morse wrote:
>>
>> Perhaps I am mistaken, but I believe you would still have to go around
>> and add that trigger to all the places the value is changed from.
>
> Well you could do something like
> Storage.prototype.setItemAndNotify =
> function (key, data) {
> this.setItem(key, data);
> var e = document.createEvent("StorageEvent");
> e.initStorageEvent(...);
> window.dispatchEvent(e);
> }
>
> and use that when you set some item.
> Or just replace setItem method using prototype.
>
> That way you get the behavior you want, but still allow the
> other behavior.
I don't think replacing setItem on the protochain will work for code that does:
localStore.bar = "baz";
(I guess chalk this up as another reason why catchalls are bad).
/ Jonas
Received on Thursday, 28 January 2010 23:53:28 UTC