Skip to content

Add fromEventTarget to Window #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
Breaking changes:

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

Bugfixes:

Expand Down
5 changes: 5 additions & 0 deletions src/Web/HTML/Window.purs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Web.HTML.Window
( Window
, toEventTarget
, fromEventTarget
, document
, navigator
, location
Expand Down Expand Up @@ -48,12 +49,16 @@ import Web.HTML.History (History)
import Web.HTML.Location (Location)
import Web.HTML.Navigator (Navigator)
import Web.Storage.Storage (Storage)
import Web.Internal.FFI (unsafeReadProtoTagged)

foreign import data Window :: Type

toEventTarget :: Window -> EventTarget
toEventTarget = unsafeCoerce

fromEventTarget :: EventTarget -> Maybe Window
fromEventTarget = unsafeReadProtoTagged "Window"

foreign import document :: Window -> Effect HTMLDocument

foreign import navigator :: Window -> Effect Navigator
Expand Down