W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2009

Re: DOMActivate vs. Click

From: Maciej Stachowiak <mjs@apple.com>
Date: Tue, 21 Jul 2009 14:13:45 -0700
Cc: Doug Schepers <schepers@w3.org>, Travis Leithead <travil@microsoft.com>, "www-dom@w3.org" <www-dom@w3.org>
Message-id: <7500D736-4965-4BC8-A9EB-423BFD4BC84B@apple.com>
To: Jacob Rossi <t-jacobr@microsoft.com>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:03 GMT