@@ -2129,6 +2129,17 @@ def _remove_element(self, el: Element, default_key: str, parent_key):
2129
2129
new_parent_key = join_key (parent_key , key )
2130
2130
self ._remove_element (self .context .root_element , "/" , parent_key = new_parent_key )
2131
2131
finally :
2132
+ try :
2133
+ assert not child_context .elements , f"left over elements { child_context .elements } "
2134
+ assert not child_context .element_to_widget , f"left over element_to_widget { child_context .element_to_widget } "
2135
+ assert not child_context .widgets , f"left over widgets { child_context .widgets } "
2136
+ assert not child_context .children , f"left over children { child_context .children } "
2137
+ assert not child_context .owns , f"left over owns { child_context .owns } "
2138
+ # TODO: this is not the case when an exception occurs
2139
+ # assert not child_context.children_next, f"left over children {child_context.children_next}"
2140
+ except Exception as e :
2141
+ child_context .exceptions_self .append (e )
2142
+
2132
2143
# restore context
2133
2144
self .context = context
2134
2145
if child_context .exceptions_self or child_context .exceptions_children and not child_context .exception_handler :
@@ -2163,14 +2174,6 @@ def _remove_element(self, el: Element, default_key: str, parent_key):
2163
2174
if el in context .element_to_widget :
2164
2175
del context .element_to_widget [el ]
2165
2176
del context .elements [key ]
2166
- if isinstance (el .component , ComponentFunction ):
2167
- assert not child_context .elements , f"left over elements { child_context .elements } "
2168
- assert not child_context .element_to_widget , f"left over element_to_widget { child_context .element_to_widget } "
2169
- assert not child_context .widgets , f"left over widgets { child_context .widgets } "
2170
- assert not child_context .children , f"left over children { child_context .children } "
2171
- assert not child_context .owns , f"left over owns { child_context .owns } "
2172
- # TODO: this is not the case when an exception occurs
2173
- # assert not child_context.children_next, f"left over children {child_context.children_next}"
2174
2177
2175
2178
def _visit_children (self , el : Element , default_key : str , parent_key : str , f : Callable ):
2176
2179
assert self .context is not None
0 commit comments