[DOM3Events] Exceptions

I removed EventException from DOM Core and I think that change makes  
sense. We use DOMException for most of our APIs. Only dispatchEvent()  
throws exceptions of this type and it seems like unneeded complexity to me.

DOM Level 3 Events says dispatchEvent() can throw these exceptions:  
EventException.UNSPECIFIED_EVENT_TYPE_ERR,  
EventException.DISPATCH_REQUEST_ERR, DOMException.NOT_SUPPORTED_ERR, and  
DOMException.INVALID_CHARACTER_ERR.

I have not been able to get implementations to throw any of the latter two  
exceptions. Examples would be most welcome. In fact the text for  
INVALID_CHARACTER_ERR seems to overlap with UNSPECIFIED_EVENT_TYPE_ERR as  
they are both talking about restrictions on Event.type. However, what the  
restrictions on Event.type are is not at all clear. Event.type only says  
that no events should be created that contain whitespace. It does not say  
anything about the empty string, or whether initializing events with  
whitespace in their type will throw an error or not (either then or later).

I do not think we need UNSPECIFIED_EVENT_TYPE_ERR at all really. Why  
should we require invoking initEvent()?

And DISPATCH_REQUEST_ERR could easily be replaced by INVALID_STATE_ERR. We  
use it that way in tons of APIs.


-- 
Anne van Kesteren
http://annevankesteren.nl/

Received on Friday, 4 March 2011 14:53:21 UTC