[whatwg] More Storage clarification

On Fri, 11 Apr 2008 01:01:46 +0200, Brady Eidson <beidson at apple.com> wrote:
> In 4.10.5, the description of the properties on the StorageEvent object  
> mentions "...its newValue attribute set to the new value of the key in  
> question, or null if the key was removed..."
> So a web author can assume that when handling a StorageEvent whose  
> newValue property is null that the event was the result of a  
> removeItem(), and the key is no longer in the list.
> However in 4.10.2 in the discussion of setItem(), there is no mention  
> that null is not an allowed value.  Something like  
> sessionStorage.setItem("key", null) is not forbidden, therefore it is  
> allowed, and it would result in a StorageEvent with a null newValue.
> To resolve this case, I propose that we specify that the value in a  
> key/value pair cannot be set to null.
> I see two clean ways to specify this:
> 1 - Throw an exception when setItem() is called with a null value.
> 2 - Specify setItem(key, null) to have the exact same effects as  
> removeItem(key).
> I prefer #2.  Thoughts?

Euhm, setItem() takes two strings. Therefore I'd expect null, undefined,  
etc. to be stringified.

Anne van Kesteren

Received on Thursday, 10 April 2008 16:06:18 UTC