Skip to content

Commit 879e724

Browse files
committed
Update kind to return Maybe
1 parent 4870dd4 commit 879e724

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/Web/HTML/Event/DataTransfer/DataTransferItem.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"use strict";
22

3-
exports._kind = function (text, file, dataTransferItem) {
3+
exports._kind = function (nothing, just, text, file, dataTransferItem) {
44
if (dataTransferItem.kind === "string") {
5-
return text;
5+
return just(text);
6+
} else if (dataTransferItem.kind === "file") {
7+
return just(file);
68
} else {
7-
return file;
9+
return nothing;
810
}
911
};
1012

src/Web/HTML/Event/DataTransfer/DataTransferItem.purs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ module Web.HTML.Event.DataTransfer.DataTransferItem
1010

1111
import Prelude
1212

13-
import Data.Function.Uncurried (Fn3)
13+
import Data.Function.Uncurried (Fn5)
1414
import Data.Function.Uncurried as Uncurried
15-
import Data.Maybe (Maybe)
15+
import Data.Maybe (Maybe(..))
1616
import Data.Nullable (Nullable)
1717
import Data.Nullable as Nullable
1818

@@ -26,11 +26,19 @@ instance Show DataTransferItemKind where
2626
Text -> "Text"
2727
File -> "File"
2828

29-
foreign import _kind :: Fn3 DataTransferItemKind DataTransferItemKind DataTransferItem DataTransferItemKind
29+
foreign import _kind
30+
:: Fn5 (forall x. Maybe x)
31+
(forall x. x -> Maybe x)
32+
DataTransferItemKind
33+
DataTransferItemKind
34+
DataTransferItem
35+
(Maybe DataTransferItemKind)
3036

31-
-- | Returns the drag data item kind, which is either "string" or "file".
32-
kind :: DataTransferItem -> DataTransferItemKind
33-
kind = Uncurried.runFn3 _kind Text File
37+
-- | Returns the drag data item kind of the `DataTransferItem`. In the case
38+
-- | where the `DataTransferItem` object is in _disabled mode_, `Nothing` is
39+
-- | returned.
40+
kind :: DataTransferItem -> Maybe DataTransferItemKind
41+
kind = Uncurried.runFn5 _kind Nothing Just Text File
3442

3543
-- | A Unicode string giving the type or format of the data, generally given by
3644
-- | a MIME type. Some values that are not MIME types are special-cased for

0 commit comments

Comments
 (0)