mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
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:
parent
069fe267b6
commit
6b2b72d6f9
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user