Skip to main content

Bug Tracker

Side navigation

#11801 closed bug (wontfix)

Opened May 22, 2012 09:28PM UTC

Closed May 22, 2012 10:39PM UTC

jQuery 1.7.2 - dragleave event has no relatedTarget in Chromium

Reported by: mtraceur@member.fsf.org Owned by: mtraceur@member.fsf.org
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!

Attachments (0)
Change History (8)

Changed May 22, 2012 09:29PM UTC by rwaldron comment:1

owner: → mtraceur@member.fsf.org
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.

Changed May 22, 2012 09:42PM UTC by mtraceur@member.fsf.org comment:2

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!

Changed May 22, 2012 10:01PM UTC by rwaldron comment:3

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.

Changed May 22, 2012 10:02PM UTC by Mark Holmquist <mtraceur@member.fsf.org> comment:4

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!

Changed May 22, 2012 10:18PM UTC by Mark Holmquist <mtraceur@member.fsf.org> comment:5

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

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

Changed May 22, 2012 10:24PM UTC by scottgonzalez comment:6

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/

Changed May 22, 2012 10:28PM UTC by Mark Holmquist <mtraceur@member.fsf.org> comment:7

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?

Changed May 22, 2012 10:39PM UTC by rwaldron comment:8

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