fix(dnd): ignore non-file drag'n'drop events #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since we only deal with files, it makes sense to ignore all events non-file related (eg. dragging
plaintext). This commit fixes a few things that have changed in the browsers which subtly break
the current checks.
The
contains
function ondt.files
has been removed from the spec and will always returnundefined. Except for IE, which hasn't implemented the change.
includes
, which we now usecontains
check in there for IE as a last resortThe dt.files property always seems to be an empty array for non-drop events. Empty arrays are
truthy, and so this will always satisfy the
isValidFileDrag
check before it can validate thatthe types array includes files
There is a drop handler which binds to the document and always prevents all default drop
behaviour from occurring, including things like dropping text into textfields
of preventing the page from navigating to the dropped file if the user misses the dropzone.
Fixes FineUploader#1588.
Brief description of the changes
{also describe what problem(s) these changes solve & reference any related issues/PRs}
What browsers and operating systems have you tested these changes on?
{example: Safari on iOS 9.1.0 and IE11 on Windows 8.1}
Have you written unit tests? If not, explain why.
{unit tests should accompany almost all PRs, unless the change is to documentation}