Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #67 from purescript-contrib/nullable-datatransfer-…
Browse files Browse the repository at this point in the history
…files

Handle cases where DataTransfer has a null +files+ slot
  • Loading branch information
garyb authored Oct 20, 2016
2 parents 26f7e54 + 34f83d9 commit f7b786d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/DOM/HTML/Event/DragEvent/DataTransfer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

exports.files = function (dataTransfer) {
exports.filesNullable = function (dataTransfer) {
return dataTransfer.files;
};

Expand Down
12 changes: 11 additions & 1 deletion src/DOM/HTML/Event/DragEvent/DataTransfer.purs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit f7b786d

Please sign in to comment.