Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def DivInDiv(self):
inner_events = idom.Events()
inner_events.on("Click", stop_propagation=True)
async def outer_click_is_not_triggered():
assert False
inner = idom.html.div(
{
"style": {"height": "30px", "width": "30px", "backgroundColor": "blue"},
"id": "inner",
},
event_handlers=inner_events,
)
outer = idom.html.div(
{
"style": {"height": "35px", "width": "35px", "backgroundColor": "red"},
"onClick": outer_click_is_not_triggered,
def test_simple_events_object():
events = idom.Events()
@events.on("Click")
async def click_handler():
pass
@events.on("keyPress")
async def key_press_handler():
pass
assert isinstance(events["onClick"], EventHandler)
assert isinstance(events["onKeyPress"], EventHandler)
assert "onClick" in events
assert "onKeyPress" in events
assert len(events) == 2
import pytest
import idom
from idom.core.vdom import make_vdom_constructor, component
fake_events = idom.Events()
@fake_events.on("Click")
async def handler(event):
pass
@pytest.mark.parametrize(
"actual, expected",
[
(
idom.vdom("div", [idom.vdom("div")]),
{"tagName": "div", "children": [{"tagName": "div"}]},
),
(
idom.vdom("div", {"style": {"backgroundColor": "red"}}),
return idom.html.div(
{
"style": {
"height": f"{block_size * grid_size}px",
"width": f"{block_size * grid_size}px",
},
"tabIndex": -1,
},
[
idom.html.div(
{"style": {"height": block_size}},
[Block("white", block_size) for i in range(grid_size)],
)
for i in range(grid_size)
],
event_handlers=idom.Events(),
)