From 34f83d991956ace694857cbd7170d09962cd3355 Mon Sep 17 00:00:00 2001 From: "Ryan L. Bell" Date: Tue, 4 Oct 2016 15:02:32 -0400 Subject: [PATCH] Handle cases where DataTransfer has a null +files+ slot --- src/DOM/HTML/Event/DragEvent/DataTransfer.js | 2 +- src/DOM/HTML/Event/DragEvent/DataTransfer.purs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/DOM/HTML/Event/DragEvent/DataTransfer.js b/src/DOM/HTML/Event/DragEvent/DataTransfer.js index 9c95d84..0eee62e 100644 --- a/src/DOM/HTML/Event/DragEvent/DataTransfer.js +++ b/src/DOM/HTML/Event/DragEvent/DataTransfer.js @@ -1,6 +1,6 @@ "use strict"; -exports.files = function (dataTransfer) { +exports.filesNullable = function (dataTransfer) { return dataTransfer.files; }; diff --git a/src/DOM/HTML/Event/DragEvent/DataTransfer.purs b/src/DOM/HTML/Event/DragEvent/DataTransfer.purs index 9792f6a..416ff44 100644 --- a/src/DOM/HTML/Event/DragEvent/DataTransfer.purs +++ b/src/DOM/HTML/Event/DragEvent/DataTransfer.purs @@ -1,16 +1,26 @@ module DOM.HTML.Event.DragEvent.DataTransfer ( DataTransfer , files + , filesNullable , types ) where +import Prelude import DOM.File.Types (FileList) +import Data.Maybe (Maybe) +import Data.Nullable (Nullable, toMaybe) foreign import data DataTransfer :: * -- | Contains a list of all the local files available on the data transfer. -- | Empty if the drag operation doesn't involve dragging files. -foreign import files :: DataTransfer -> FileList +-- | +-- | It's possible that a drag operation may have null files, instead of an +-- | empty file list. In these cases Nothing is returned. +files :: DataTransfer -> Maybe FileList +files = toMaybe <$> filesNullable + +foreign import filesNullable :: DataTransfer -> Nullable FileList -- | Returns an array of data formats used in the drag operation. -- | If the drag operation included no data, then the array is empty.