File tree 3 files changed +10
-6
lines changed
3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 24
24
from .events import EventHandler , EventTarget
25
25
from .hooks import LifeCycleHook
26
26
from .utils import CannotAccessResource , HasAsyncResources , async_resource
27
- from .vdom import validate_serialized_vdom
27
+ from .vdom import validate_vdom
28
28
29
29
30
30
logger = getLogger (__name__ )
@@ -104,13 +104,17 @@ async def render(self) -> LayoutUpdate:
104
104
return self ._create_layout_update (component )
105
105
106
106
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
+
107
111
_debug_render = render
108
112
109
113
@wraps (_debug_render )
110
114
async def render (self ) -> LayoutUpdate :
111
115
# Ensure that the model is valid VDOM on each render
112
116
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 )
114
118
return result
115
119
116
120
@async_resource
Original file line number Diff line number Diff line change 63
63
}
64
64
65
65
66
- validate_serialized_vdom = compile_json_schema (VDOM_JSON_SCHEMA )
66
+ validate_vdom = compile_json_schema (VDOM_JSON_SCHEMA )
67
67
68
68
69
69
class ImportSourceDict (TypedDict ):
Original file line number Diff line number Diff line change 2
2
from fastjsonschema import JsonSchemaException
3
3
4
4
import 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
6
6
7
7
8
8
fake_events = idom .Events ()
@@ -213,7 +213,7 @@ def MyComponentWithChildrenAndAttributes(children, x):
213
213
],
214
214
)
215
215
def test_valid_vdom (value ):
216
- validate_serialized_vdom (value )
216
+ validate_vdom (value )
217
217
218
218
219
219
@pytest .mark .parametrize (
@@ -312,4 +312,4 @@ def test_valid_vdom(value):
312
312
)
313
313
def test_invalid_vdom (value , error_message_pattern ):
314
314
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