Skip to content

Commit 708f577

Browse files
committed
Add unit test + changelog
1 parent 5d03ea7 commit 708f577

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Don't forget to remove deprecated code on each major release!
2121
- Added support for inline JavaScript as event handlers or other attributes that expect a callable via `reactpy.types.InlineJavaScript`
2222
- Event functions can now call `event.preventDefault()` and `event.stopPropagation()` methods directly on the event data object, rather than using the `@event` decorator.
2323
- Event data now supports accessing properties via dot notation (ex. `event.target.value`).
24+
- Added support for partial functions in EventHandler
2425
- Added `reactpy.types.Event` to provide type hints for the standard `data` function argument (for example `def on_click(event: Event): ...`).
2526
- Added `asgi` and `jinja` installation extras (for example `pip install reactpy[asgi, jinja]`).
2627
- Added `reactpy.executors.asgi.ReactPy` that can be used to run ReactPy in standalone mode via ASGI.

tests/test_core/test_events.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22

33
import reactpy
4+
from functools import partial
45
from reactpy import component, html
56
from reactpy.core.events import (
67
EventHandler,
@@ -348,6 +349,16 @@ def handler(event: Event):
348349
assert eh.stop_propagation is True
349350

350351

352+
def test_detect_both_when_handler_is_partial():
353+
def handler(event: Event, *, extra_param):
354+
event.preventDefault()
355+
event.stopPropagation()
356+
357+
eh = EventHandler(partial(handler, extra_param="extra_value"))
358+
assert eh.prevent_default is True
359+
assert eh.stop_propagation is True
360+
361+
351362
def test_no_detect():
352363
def handler(event: Event):
353364
pass

0 commit comments

Comments
 (0)