Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

MDL-44270 files: handle drag-drop js error when event has null types

This can happen when the 'dragover' event fires as has been observed
in Safari. When the dataTransfer.types property of the event is null,
accessing types.length throws a JavaScript error.
  • Loading branch information...
commit 911d3e9f0b2883e108e2e34092c4c16a66ab5741 1 parent c16911b
@jonof jonof authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/form/dndupload.js
5 lib/form/dndupload.js
@@ -355,7 +355,10 @@ M.form_dndupload.init = function(Y, options) {
* @return boolean true if event has files
has_files: function(e) {
- var types = e._event.dataTransfer.types;
+ // In some browsers, dataTransfer.types may be null for a
+ // 'dragover' event, so ensure a valid Array is always
+ // inspected.
+ var types = e._event.dataTransfer.types || [];
for (var i=0; i<types.length; i++) {
if (types[i] == 'Files') {
return true;

0 comments on commit 911d3e9

Please sign in to comment.
Something went wrong with that request. Please try again.