[whatwg] More Storage clarification

Brady Eidson beidson at apple.com
Thu Apr 10 16:01:46 PDT 2008


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




More information about the whatwg mailing list