|
25 | 25 | from .component import AbstractComponent |
26 | 26 | from .events import EventHandler |
27 | 27 | from .hooks import LifeCycleHook |
28 | | -from .utils import CannotAccessResource, HasAsyncResources, async_resource |
| 28 | +from .utils import CannotAccessResource, HasAsyncResources, async_resource, hex_id |
29 | 29 | from .vdom import validate_vdom |
30 | 30 |
|
31 | 31 |
|
@@ -251,7 +251,7 @@ def _render_model_event_handlers_without_old_state( |
251 | 251 |
|
252 | 252 | model_event_handlers = new_state.model["eventHandlers"] = {} |
253 | 253 | for event, handler in handlers_by_event.items(): |
254 | | - target = hex(id(handler))[2:] |
| 254 | + target = hex_id(handler) |
255 | 255 | new_state.targets_by_event[event] = target |
256 | 256 | self._event_handlers[target] = handler |
257 | 257 | model_event_handlers[event] = { |
@@ -285,10 +285,10 @@ def _render_model_children( |
285 | 285 | for index, child in enumerate(raw_children): |
286 | 286 | if isinstance(child, dict): |
287 | 287 | child_type = DICT_TYPE |
288 | | - key = child.get("key") or hex(id(child))[2:] |
| 288 | + key = child.get("key") or hex_id(child) |
289 | 289 | elif isinstance(child, AbstractComponent): |
290 | 290 | child_type = COMPONENT_TYPE |
291 | | - key = getattr(child, "key", None) or hex(id(child))[2:] |
| 291 | + key = getattr(child, "key", None) or hex_id(child) |
292 | 292 | else: |
293 | 293 | child = str(child) |
294 | 294 | child_type = STRING_TYPE |
@@ -336,13 +336,13 @@ def _render_model_children_without_old_state( |
336 | 336 | new_children = new_state.model["children"] = [] |
337 | 337 | for index, child in enumerate(raw_children): |
338 | 338 | if isinstance(child, dict): |
339 | | - key = child.get("key") or hex(id(child)) |
| 339 | + key = child.get("key") or hex_id(child) |
340 | 340 | child_state = _ModelState(new_state, index, key, None) |
341 | 341 | self._render_model(None, child_state, child) |
342 | 342 | new_children.append(child_state.model) |
343 | 343 | new_state.children_by_key[key] = child_state |
344 | 344 | elif isinstance(child, AbstractComponent): |
345 | | - key = getattr(child, "key", "") or hex(id(child)) |
| 345 | + key = getattr(child, "key", "") or hex_id(child) |
346 | 346 | life_cycle_hook = LifeCycleHook(child, self) |
347 | 347 | child_state = _ModelState(new_state, index, key, life_cycle_hook) |
348 | 348 | self._render_component(None, child_state, child) |
|
0 commit comments