Re: DOMActivate vs. Click

On Jul 21, 2009, at 1:27 PM, Jacob Rossi wrote:

> As I understand it, the purpose of DOMActivate is to remove the  
> device dependence of an element’s associated behavior. So, clicking  
> on a hyperlink causes a click event whose default action is to fire  
> DOMActivate. The default action of the DOMActivate would then be to  
> navigate to the page. Calling preventDefault() on either would  
> prevent the navigation from occurring.
>
> I understand that associated activation behaviors can be invoked via  
> different device interactions (using the keyboard while the link is  
> focused). But if DOMActivate is supposed to remove the device  
> dependence, why does the spec say: “when a user activates a  
> hyperlink using a keyboard, the click event would be dispatched as  
> default action of the respective keyboard event.”
>
> Shouldn’t it be that activating the hyperlink with the keyboard  
> causes a DOMActivate event which is dispatched as the default action  
> of the respective keyboard event? Otherwise, why have the  
> DOMActivate event if the activation behavior is going to have some  
> “default” event associated with it which all other device  
> interactions are supposed to synthesize.
>
> It seems to me that firing a click event as the default action of an  
> interaction via a device other than a mouse is not intuitive  
> (especially since it is a MouseEvent and will have a number of  
> associated attributes which are nonsensical).

You correctly described the original intended purpose of DOMActivate.

Unfortunately, Web compatibility requires sending a "click" event for  
non-mouse-driven activations. In particular, it is a common practice  
to give an <a> element or an <input type="button"> element an onclick  
attribute and the page author expects it to trigger even for keyboard  
activation. This practice precedes the existence of the DOMActivate  
event and remains common. Authors almost never use a DOMActivate  
handler instead.

Thus, it is necessary to still dispatch a "click" event for non-mouse  
activation.

Regards,
Maciej

Received on Tuesday, 21 July 2009 21:14:28 UTC