Bug Tracker

Opened 7 years ago

Closed 7 years ago

#11801 closed bug (wontfix)

jQuery 1.7.2 - dragleave event has no relatedTarget in Chromium

Reported by: mtraceur@… Owned by: mtraceur@…
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

Hi!

I'm trying to use jQuery event objects to catch different kinds of drag events in a cross-browser way. Funny thing is, each browser is apparently different, even with jQuery!

The way I figured out to test for the proper dragleave event on Firefox was, if the relatedTarget was null, then clearly the dragleave event was for the entire window (which was what I wanted), and if the DOM node referred to by relatedTarget either gave me an error when I tried to access it or was not contained by document.body, then clearly it wasn't inside of document.body.

In Chromium, however, jQuery apparently can't figure out what the relatedTarget is. This is somewhat painful to debug, and (I imagine) would be even more painful to work around, since now every single dragleave event that bubbles up to document.body appears to be exactly the same--I tried filtering out the ones where srcElement !== currentTarget, but a few still get through. That doesn't make a whole lot of sense, because none of the events that are firing were caused by an actual dragleave. The mouse is still inside of the window.

Any help with this would be awesome. Thanks so much!

Change History (8)

comment:1 Changed 7 years ago by Rick Waldron

Owner: set to mtraceur@…
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the "jQuery (edge)" version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to begin.

comment:2 Changed 7 years ago by mtraceur@…

Status: pendingnew

Hi!

I'd much rather avoid using non-free software (i.e., jsFiddle) to accomplish this particular task, is there some other way I can help you with a test case?

Anyway, the simplest way to explain it is "when I'm dragging over a page, and a dragleave event fires, relatedTarget should never be null, and it probably should never be the same as currentTarget". I can translate that into JavaScript if you'd like, but it's pretty straightforward.

Cheers!

comment:3 Changed 7 years ago by Rick Waldron

Status: newpending

We post the bug report guidelines on the same page that you used to submit this report - we're volunteers and it's time consuming to translate your description of a problem into a usable test case reproduction.

jsFiddle is free to use for anyone.

comment:4 Changed 7 years ago by Mark Holmquist <mtraceur@…>

In the interest of solving this more quickly,

http://jsfiddle.net/3ayZk/1/

Drag a file over the divs in order in chromium, the "null" message should appear many times. This is unhelpful when trying to determine where the drag is going....

That being said, it would be very helpful in the future to have a free way of making unit tests. And I do mean free as in freedom, though I'm sorry I have to specify at the site of a free project :)

Thanks again!

comment:5 Changed 7 years ago by Mark Holmquist <mtraceur@…>

Sorry, it didn't properly save the thing. Here's the proper link:

http://jsfiddle.net/3ayZk/5/

comment:6 Changed 7 years ago by scottgonzalez

jQuery doesn't do any special normalization for drag events. This doesn't seem to be a bug in jQuery: http://jsfiddle.net/3ayZk/6/

comment:7 Changed 7 years ago by Mark Holmquist <mtraceur@…>

Fair enough, could you switch it to be a feature request, or do I need to re-submit? It seems like exactly the sort of thing it might be helpful to have around, for cross-browser compatibility.

So I suppose, in the meantime, I'm stuck not knowing when a dragleave event is real?

comment:8 Changed 7 years ago by Rick Waldron

Resolution: wontfix
Status: pendingclosed

The only specification of a relatedTarget value is setting it to null:

the relatedTarget attribute initialized to null

There is no direct link, but control-F for "relatedTarget" http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#event-dragleave

Note: See TracTickets for help on using tickets.