Skip to content
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
8 changes: 8 additions & 0 deletions src/React/Basic/DOM/Components/GlobalEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,11 @@ GlobalEvent.prototype.render = function() {
};

exports.globalEvent_ = GlobalEvent;

exports.unsafeWindowEventTarget = (function() {
if (typeof window === "undefined") {
return undefined;
} else {
return window;
}
})();
7 changes: 3 additions & 4 deletions src/React/Basic/DOM/Components/GlobalEvents.purs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ import Prelude

import Data.Foldable (foldr)
import Effect (Effect)
import Effect.Unsafe (unsafePerformEffect)
import React.Basic (JSX, ReactComponent, element)
import Web.Event.Event (EventType)
import Web.Event.Internal.Types (Event, EventTarget)
import Web.HTML (window)
import Web.HTML.Window as Window

type EventHandlerOptions =
{ capture :: Boolean
Expand Down Expand Up @@ -100,7 +97,7 @@ windowEvents
}
-> JSX
-> JSX
windowEvents = globalEvents $ unsafePerformEffect $ map Window.toEventTarget window
windowEvents = globalEvents unsafeWindowEventTarget

windowEvent
:: { eventType :: EventType
Expand All @@ -111,6 +108,8 @@ windowEvent
-> JSX
windowEvent = windowEvents <<< pure

foreign import unsafeWindowEventTarget :: EventTarget

-- | Hide "unused ffi export" warning.
-- | The export is required to prevent
-- | PS' bundler from stripping it out.
Expand Down