[whatwg] More Storage clarification

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?

~Brady

Received on Thursday, 10 April 2008 16:01:46 UTC