Open Bug 919631 Opened 11 years ago Updated 4 years ago

drageenter and dragleave are not fired in balanced pairs.

Categories

(Core :: DOM: Events, defect, P5)

24 Branch
x86
macOS
defect

Tracking

()

UNCONFIRMED

People

(Reporter: alex, Unassigned)

References

()

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36

Steps to reproduce:

See the following jsFiddle: http://jsfiddle.net/a4fet/2/


Actual results:

The number of dragenter events exceeds the number of dragleave events. It seems that 2 dragenter events are fired when the drag begins, and the counter never returns to 0.


Expected results:

The number of dragenter events should equal the number of dragleave events, whenever the draggable is dragged outside of the droppable. This is the behaviour exhibited by Chrome 29.0.1547.65; the counter always returns to 0.
Corrected a typo in the fiddle; use http://jsfiddle.net/a4fet/3/
Component: Untriaged → DOM: Events
Product: Firefox → Core
Alexander, I believe your specific code could be fixed by ignoring events fired on text nodes (which is another bug), but I think the general problem here still exists.

I've put together an example that works in the latest Chrome, Opera, Safari, and IE (both 10 and IE11 preview), but not Firefox.

I'm using a counter to balance out the element's children's `dragenter` and `dragleave` events, but they don't seem to be balanced in Firefox. I believe in some cases the `dragleave` event is firing before the `dragenter` event, but it's hard to tell. Either way, the count is off in Firefox, but not in any other browser.

This is a big problem for detecting when a user has dragged out of an element that contains child elements. A common problem for drag-and-drop file upload pages.
Sorry, I forgot to include my demo:
http://codepen.io/philipwalton/pen/LmcGp
This bug looks like the oddity that I encountered here.
http://ikilote.net/Programmation/JavaScript/DragNDrop/etape6.htm
Move “bloc” and see the console.

Bulk-downgrade of unassigned, >=5 years untouched DOM/Storage bugs' priority.

If you have reason to believe this is wrong (especially for the severity), please write a comment and ni :jstutte.

Severity: normal → S4
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.