w3c / uievents

UI Events
https://w3c.github.io/uievents/
Other
147 stars 52 forks source link

The specification of `relatedTarget` property of `mouseover` reads "indicates the event target a pointing device is entering, if any." but should read "exiting" #307

Open sbates-idrc opened 3 years ago

sbates-idrc commented 3 years ago

I believe that I have found a bug in the specification of the relatedTarget property of the mouseover event. The specification differs from what I am seeing in Firefox, Chrome, and Edge. And differs from the Mozilla documentation and the specification of the related mouseenter event.

The specification of the relatedTarget property of the mouseover event (https://w3c.github.io/uievents/#event-type-mouseover) reads:

"indicates the event target a pointing device is entering, if any."

But I think that it should read:

"indicates the event target a pointing device is exiting, if any."

When testing mouseover events in Firefox, Chrome, and Edge I see that the relatedTarget property is set to the element that the pointer exited. I have created a test file here: https://gist.github.com/sbates-idrc/b47ebb07ab95a4e50dd64b7933351de1

Moving the pointer from div A to div B results in the following being logged:

This behaviour is consistent with the Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/relatedTarget

The specifiicaion of the relatedTarget property of the mouseenter event reads: "indicates the event target a pointing device is exiting, if any." (https://w3c.github.io/uievents/#event-type-mouseenter)

garykac commented 3 years ago

Ah Good catch. Thanks for reporting this.

I've updated the Mouse Event Viewer at https://domeventviewer.com/mouse-event-viewer.html to show relatedTarget (off by default though, use "Show Options" to enable).