Skip to content
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

Propagate SyntheticEvent to 'this' in preventDefault and stopPropagation functions #48

Merged
merged 1 commit into from
Jan 11, 2023
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
5 changes: 5 additions & 0 deletions src/React/Basic/DOM/Events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"use strict";

export const propagateThis = (f) => (t) => () => {
return f.call(t);
}
6 changes: 4 additions & 2 deletions src/React/Basic/DOM/Events.purs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ nativeEvent = unsafeEventFn \e -> (unsafeCoerce e).nativeEvent

preventDefault :: EventFn SyntheticEvent SyntheticEvent
preventDefault = unsafeEventFn \e -> unsafePerformEffect do
_ <- (unsafeCoerce e).preventDefault
_ <- propagateThis (unsafeCoerce e).preventDefault e
pure e

isDefaultPrevented :: EventFn SyntheticEvent Boolean
Expand All @@ -111,7 +111,7 @@ isDefaultPrevented = unsafeEventFn \e -> unsafePerformEffect do

stopPropagation :: EventFn SyntheticEvent SyntheticEvent
stopPropagation = unsafeEventFn \e -> unsafePerformEffect do
_ <- (unsafeCoerce e).stopPropagation
_ <- propagateThis (unsafeCoerce e).stopPropagation e
pure e

isPropagationStopped :: EventFn SyntheticEvent Boolean
Expand Down Expand Up @@ -207,3 +207,5 @@ clipboardData = unsafeEventFn \e -> toMaybe (unsafeCoerce e).clipboardData
-- \ Composition Events
compositionData :: EventFn SyntheticEvent (Maybe String)
compositionData = unsafeEventFn \e -> toMaybe (unsafeCoerce e).data

foreign import propagateThis :: forall f t a. f -> t -> Effect a