From ea0df6ebe20795ad86ad87b1ff919c072054398b Mon Sep 17 00:00:00 2001 From: Tom Hunger Date: Sat, 10 Sep 2016 11:25:39 +0100 Subject: [PATCH] Introduce preventDefault and stopPropagation. See #83. --- src/React.js | 10 ++++++++++ src/React.purs | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/src/React.js b/src/React.js index 9a7188e..52d3aa2 100644 --- a/src/React.js +++ b/src/React.js @@ -152,3 +152,13 @@ function createFactory(class_) { return React.createFactory(class_); } exports.createFactory = createFactory; + +function preventDefault(event) { + return function() { return event.preventDefault();} +}; +exports.preventDefault = preventDefault; + +function stopPropagation(event) { + return function() { return event.stopPropagation();} +}; +exports.stopPropagation = stopPropagation; diff --git a/src/React.purs b/src/React.purs index 14b7b43..17ba0ff 100644 --- a/src/React.purs +++ b/src/React.purs @@ -51,6 +51,8 @@ module React , transformState , handle + , preventDefault + , stopPropagation , createClass , createClassStateless @@ -362,3 +364,7 @@ foreign import data Children :: * -- | Internal conversion function from children elements to an array of React elements foreign import childrenToArray :: Children -> Array ReactElement + +foreign import preventDefault :: forall eff a. Event -> Eff eff a + +foreign import stopPropagation :: forall eff a. Event -> Eff eff a