bevacqua / dragula

:ok_hand: Drag and drop so simple it hurts
https://bevacqua.github.io/dragula/
MIT License
21.89k stars 1.97k forks source link

fix: allow calling release without argument #572

Open lddubeau opened 5 years ago

lddubeau commented 5 years ago

Calling release({}) used to be okay. The code of release would try to grab clientX/Y from the empty object, get undefined for both coordinate, and feed them to elementFromPoint. elementFromPoint was fine with that and just returned null. However a recent Chrome change broke this. Chrome now checks that the coordinates passed to elementFromPoint are finite doubles and so passing undefined no longer works.

This commit makes it so that calling release without an event object works. It will just skip trying to find a drop target.

As I was submitting this PR, I noticed another PR for the same issue. However, I disagree with the solution provided there. Calling release with clientX and clientY arbitrarily set to -1 is not safe as the coordinates -1, -1 can be pointing to a legitimate element for some use-case scenarios. Rare? Yes, but it can happen.