This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22641 - Normatively specify the order in which mouse events should fire
Summary: Normatively specify the order in which mouse events should fire
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - DOM3 Events (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Travis Leithead [MSFT]
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-11 01:07 UTC by Gordon P. Hemsley
Modified: 2013-10-23 13:51 UTC (History)
6 users (show)

See Also:


Attachments

Description Gordon P. Hemsley 2013-07-11 01:07:50 UTC
When a mouse cursor is moved over an element, three events are fired (in some order):

* mouseover
* mouseenter
* mousemove

Possible orders include:

(1) mouseover -> mouseenter -> mousemove
(2) mousenter -> mouseover -> mousemove
(3) mousemove -> mouseover -> mouseenter

The spec suggests (non-normatively, AIUI) order (1). According to [1] (and some of my own testing), Gecko uses order (1). Opera uses order (2), which is IMO the most logical. IE uses order (3). Chrome and Safari could use either order (1) or order (2), as neither currently fires the mouseenter event. (I'm told a patch has recently landed for Chrome support, but I haven't verified what order that implements.)

Interestingly enough, Opera seem to agree that the canonical order for the reverse is (4):

(4) mousemove -> mouseout -> mouseleave

As before, Chrome and Opera do not fire the mouseleave event, but otherwise maintain the order in (4). I didn't test IE.

The spec should say definitively, and not just in some examples or suggestions, what the canonical order should be.

[1] http://rodneyrehm.github.io/select-events/
Comment 1 Gordon P. Hemsley 2013-07-11 01:08:55 UTC
(In reply to comment #0)
> Interestingly enough, Opera seem to agree that the canonical order for the
> reverse is (4):
> 
> (4) mousemove -> mouseout -> mouseleave
> 
> As before, Chrome and Opera do not fire the mouseleave event, but otherwise
> maintain the order in (4). I didn't test IE.

Wow, lots of typos. That first line should say "Gecko and Opera" and that second line should say "Chrome and Safari".
Comment 2 Olli Pettay 2013-07-11 02:20:37 UTC
http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-mouseevent-event-order
and Gecko follows that.

Feel free to re-open if there is something unclear in the spec.
The order of mouseover/enter and mouseout/leave should be clear.
Comment 3 Ian 'Hixie' Hickson 2013-07-12 17:50:27 UTC
That isn't normative.
Comment 4 Gordon P. Hemsley 2013-07-16 22:24:53 UTC
The Chrome implementation is here:

http://src.chromium.org/viewvc/blink?view=revision&revision=153877

According to [1], Chrome seems to use order (2) from comment 0 for the entry (like Opera), but order (5) below for the exit:

(5) mouseleave -> mouseout

(I didn't test this myself, so I don't know where 'mousemove' falls into the order.)

[1]: http://src.chromium.org/viewvc/blink/trunk/LayoutTests/fast/events/mouseenter-mouseleave-expected.txt?pathrev=153877
Comment 5 Gary Kacmarcik 2013-10-23 13:51:14 UTC
I've updated the text in the ED to mark the
   over - enter - move - out - leave
order as normative.

FF and IE both use the above order.

IE also has a single extra move before the over, which we are having them investigate. We believe that it is there to work around some issues with touch devices, but we'll track that as a separate issue if needed.

Safari 6.0.5 and Chrome 29 don't yet have enter/leave.


For reference/testing browser mouse events, I created:
https://dvcs.w3.org/hg/d4e/raw-file/tip/mouse-event-test.html