W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2011

Click event on button element when event targets of the associated mousedown and mouseup are different

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Thu, 14 Apr 2011 17:44:52 -0700
Message-ID: <BANLkTimqoYnWRB1Af2ZzB_My2yxXHvSjyg@mail.gmail.com>
To: www-dom@w3.org
Greetings all,

5.2.3.2. Mouse Event
Order<http://www.w3.org/TR/DOM-Level-3-Events/#events-mouseevent-event-order>
has
the following statement:

in general should fire
click<http://www.w3.org/TR/DOM-Level-3-Events/#event-type-click>
 anddblclick <http://www.w3.org/TR/DOM-Level-3-Events/#event-type-dblclick>
events
when the event target of the associated
mousedown<http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mousedown>
 and mouseup <http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mouseup>
events
is the same element with no
mouseout<http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mouseout>
 or mouseleave<http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mouseleave>
events
intervening, and should not fire
click<http://www.w3.org/TR/DOM-Level-3-Events/#event-type-click>
 and dblclick <http://www.w3.org/TR/DOM-Level-3-Events/#event-type-dblclick>
events
when the event target of the associated
mousedown<http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mousedown>
 and mouseup <http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mouseup>
events
is different.

Unfortunately, this convention leads to the WebKit bug
39620<https://bugs.webkit.org/show_bug.cgi?id=39620>.
 In this bug, we have the following markup:

<button> www <span> DOM </span> level 3</button>

and user

   1. mousedown on DOM
   2. mosemove to www / level 3
   3. mouseup in www / level 3

WebKit currently does not fire click event on the button element per spec.
However, Firefox fires mouseup, mousedown, and click events on the button
element (it doesn't seem to ever fire mouseup, mousedown, click events on
descendents of a button element), and Internet Explorer seems to always fire
click event on the lowest common ancestor of target nodes of mouseup and
mousedown.

I personally think Internet Explorer's behavior is most desirable because
user shouldn't have to worry about element boundaries when clicking on
something.  And websites that want old behavior can always compare the
target nodes of the associated mousedown/mouseup events and drop the ones
that don't match up.

Does anyone know why the said statement was added to the spec?  Are there
any websites that break if WebKit changed the behavior?

Best,
Ryosuke Niwa
Software Engineer
Google Inc.
Received on Friday, 15 April 2011 00:45:40 GMT

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