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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user