Permalink
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...
jonof committed Apr 15, 2014
1 parent c16911b commit 911d3e9f0b2883e108e2e34092c4c16a66ab5741
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/form/dndupload.js
View
@@ -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.