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

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

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Fri, 15 Apr 2011 12:59:14 +0300
Message-ID: <4DA816F2.60605@helsinki.fi>
To: Ryosuke Niwa <rniwa@webkit.org>
CC: www-dom@w3.org
On 04/15/2011 12:54 PM, Olli Pettay wrote:
> On 04/15/2011 03:44 AM, Ryosuke Niwa wrote:
>> 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>
>> 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
>> 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>.
>
> Nope, it is not the DOM 3 Events definition of click which leads to that
> bug. It is the hit testing. In Firefox hit testing leads mouse events to
> be dispatched to button element and click event dispatching to
> work per the spec also in this case.

I could still add that the reason for Firefox's behavior is HTML 4 spec
"Buttons created with the BUTTON element function just like buttons 
created with the INPUT element, but they offer richer rendering 
possibilities"


-Olli



>
>
>> 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.
> Hmm, yeah IE's behavior might be good in general, but
> hit testing on button element should still be defined somewhere (not
> D3E) - atm hit testing isn't defined anywhere.
>
>
> -Olli
>
>> 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 09:59:37 GMT

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