Skip to content

Commit e057469

Browse files
Add fromEventTarget to Window (#53)
1 parent 0fa9b8d commit e057469

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
77
Breaking changes:
88

99
New features:
10+
- Added `fromEventTarget` function for `Window` (#53 by @thomashoneyman)
1011

1112
Bugfixes:
1213

src/Web/HTML/Window.purs

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Web.HTML.Window
22
( Window
33
, toEventTarget
4+
, fromEventTarget
45
, document
56
, navigator
67
, location
@@ -48,12 +49,16 @@ import Web.HTML.History (History)
4849
import Web.HTML.Location (Location)
4950
import Web.HTML.Navigator (Navigator)
5051
import Web.Storage.Storage (Storage)
52+
import Web.Internal.FFI (unsafeReadProtoTagged)
5153

5254
foreign import data Window :: Type
5355

5456
toEventTarget :: Window -> EventTarget
5557
toEventTarget = unsafeCoerce
5658

59+
fromEventTarget :: EventTarget -> Maybe Window
60+
fromEventTarget = unsafeReadProtoTagged "Window"
61+
5762
foreign import document :: Window -> Effect HTMLDocument
5863

5964
foreign import navigator :: Window -> Effect Navigator

0 commit comments

Comments
 (0)