On Thu, Jan 28, 2010 at 3:38 PM, Olli Pettay <olli.pet...@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