File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed
Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 2424from .events import EventHandler , EventTarget
2525from .hooks import LifeCycleHook
2626from .utils import CannotAccessResource , HasAsyncResources , async_resource
27- from .vdom import validate_serialized_vdom
27+ from .vdom import validate_vdom
2828
2929
3030logger = getLogger (__name__ )
@@ -104,13 +104,17 @@ async def render(self) -> LayoutUpdate:
104104 return self ._create_layout_update (component )
105105
106106 if IDOM_DEBUG_MODE .get ():
107+ # If in debug mode inject a function that ensures all returned updates
108+ # contain valid VDOM models. We only do this in debug mode in order to
109+ # avoid unnecessarily impacting performance.
110+
107111 _debug_render = render
108112
109113 @wraps (_debug_render )
110114 async def render (self ) -> LayoutUpdate :
111115 # Ensure that the model is valid VDOM on each render
112116 result = await self ._debug_render ()
113- validate_serialized_vdom (self ._component_states [id (self .root )].model )
117+ validate_vdom (self ._component_states [id (self .root )].model )
114118 return result
115119
116120 @async_resource
Original file line number Diff line number Diff line change 6363}
6464
6565
66- validate_serialized_vdom = compile_json_schema (VDOM_JSON_SCHEMA )
66+ validate_vdom = compile_json_schema (VDOM_JSON_SCHEMA )
6767
6868
6969class ImportSourceDict (TypedDict ):
Original file line number Diff line number Diff line change 22from fastjsonschema import JsonSchemaException
33
44import idom
5- from idom .core .vdom import component , make_vdom_constructor , validate_serialized_vdom
5+ from idom .core .vdom import component , make_vdom_constructor , validate_vdom
66
77
88fake_events = idom .Events ()
@@ -213,7 +213,7 @@ def MyComponentWithChildrenAndAttributes(children, x):
213213 ],
214214)
215215def test_valid_vdom (value ):
216- validate_serialized_vdom (value )
216+ validate_vdom (value )
217217
218218
219219@pytest .mark .parametrize (
@@ -312,4 +312,4 @@ def test_valid_vdom(value):
312312)
313313def test_invalid_vdom (value , error_message_pattern ):
314314 with pytest .raises (JsonSchemaException , match = error_message_pattern ):
315- validate_serialized_vdom (value )
315+ validate_vdom (value )
You can’t perform that action at this time.
0 commit comments