<div class="gmail_quote">On Fri, May 22, 2009 at 5:41 PM, Jeremy Orlow <span dir="ltr"><<a href="mailto:jorlow@google.com">jorlow@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>What is the behavior of the following supposed to be?<br><br><div>window.sessionStorage.removeItem = function(x) { alert("Wait, this works?"); };</div><div>window.sessionStorage.removeItem('blah');</div>

<div>alert(typeof window.sessionStorage.removeItem);</div><div><br></div><div>Safari shows 2 alerts, and the second one says 'function'.</div><div>IE8 says "object doesn't support this property or method" if line 2 isn't commented out.  It returns type string when it is.</div>

<div>Mozilla also won't run if line 2 is there, but it returns type object for line 3.</div><div><br></div><div>It seems to me that if IE8's behavior is correct, those parameters should be marked as read-only since overriding them could only be used to shoot yourself in the foot.</div>

<div><br></div><div>If Safari's implementation is correct (and it's good for the implementations to be overridable), then I believe there needs to be some safe way to make .clear() usable again.  (Otherwise, once you override removeItem() and clear(), there's not really any way to recover.)</div>
</div></blockquote><div><br></div><div>Never mind.  "delete window.localStorage.clear;" should handle this use case.</div><div><br></div><div>That said, IE8 doesn't support the delete operator in this fashion and .clear() does not reset functions in Safari 4 (beta).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div>The spec would also need to make it clear that removeItem, setItem, etc are special and should not be serialized to disk.</div>

<div><br></div><div>Apologies if this is clear in the spec and I somehow missed it.  But, if not, I think a clarification might be necessary.</div><div><br></div><div>J</div></div>
</blockquote></div><br>