[whatwg] Overriding functions in DOM Storage

Jeremy Orlow jorlow at google.com
Thu Jun 11 15:45:46 PDT 2009

On Thu, Jun 11, 2009 at 2:05 PM, Jeremy Orlow <jorlow at google.com> wrote:

> On Thu, Jun 11, 2009 at 12:36 PM, Jeremy Orlow <jorlow at google.com> wrote:
>> On Thu, Jun 11, 2009 at 11:52 AM, Ian Hickson <ian at hixie.ch> wrote:
>>> On Fri, 22 May 2009, Jeremy Orlow wrote:
>>> >
>>> > What is the behavior of the following supposed to be?
>>> >
>>> > window.sessionStorage.removeItem = function(x) { alert("Wait, this
>>> works?"); };
>>> > window.sessionStorage.removeItem('blah');
>>> > alert(typeof window.sessionStorage.removeItem);
>>> The behaviour of these things are defined in WebIDL:
>>>   http://dev.w3.org/2006/webapi/WebIDL/
>>> ...which, as defined today, consists of setting 'removeItem' to a
>>> function
>>> value that doesn't persist.
>> Apologies.  I have looked through that, but apparently not closely enough.
>>  The relevant portions of the HTML 5 spec + all the specs it depends on is a
>> lot to grok...hence the occasional question like this.
>> Thanks for the response!
> Also, does this mean that setting removeItem to null is ok?  What about
> other (non-function) objects?
> What specific portion of WebIDL talks about this?  I'm having trouble
> finding it.

Sorry, but one more question (that I'm sure the spec answers, but I can't
find that answer via searching):

What takes precedent when you do the following?

window.localStorage.setItem("removeItem", "blah");
window.localStorage.removeItem = function (x) { // do something };

In Safari 4, the alert will show "blah".  Is this correct?

Also, what's the intended behavior when doing a "delete
window.localStorage.removeItem" after all of this?  Should it delete both
entries, just the function, or just the local storage map entry?  If it's
one of the latter, should a subsequent delete call delete the other?

I assume from what you said that a "window.localStorage.clear()" after
"blah"); window.localStorage.removeItem = function (x) { // do something };"
should leave just the function override?

Does the complexity of these corner cases worry anyone else?  :-)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090611/0e6d94b0/attachment-0002.htm>

More information about the whatwg mailing list