@@ -1476,7 +1476,7 @@ def format(reason: RerenderReason):
1476
1476
for el in self ._shared_elements_next :
1477
1477
logger .debug ("\t %r %x" , el , id (el ))
1478
1478
1479
- logger .debug ("Current elements:" )
1479
+ logger .debug ("Current elements: %r" , self . _shared_elements )
1480
1480
for el in self ._shared_elements :
1481
1481
logger .debug ("\t %r %x" , el , id (el ))
1482
1482
if self .context_root .exceptions_children :
@@ -1564,7 +1564,10 @@ def format(reason: RerenderReason):
1564
1564
1565
1565
value = html .escape (error )
1566
1566
from . import ipywidgets as w
1567
+ from pprint import pprint
1567
1568
1569
+ print ("EXCEPTION FROM REACTON" , value , "\n " )
1570
+ pprint (self .container )
1568
1571
return self .render (w .HTML (value = "<pre>" + value + "</pre>" , layout = w .Layout (overflow = "auto" )), self .container )
1569
1572
else :
1570
1573
raise exc
@@ -2129,6 +2132,17 @@ def _remove_element(self, el: Element, default_key: str, parent_key):
2129
2132
new_parent_key = join_key (parent_key , key )
2130
2133
self ._remove_element (self .context .root_element , "/" , parent_key = new_parent_key )
2131
2134
finally :
2135
+ try :
2136
+ assert not child_context .elements , f"left over elements { child_context .elements } "
2137
+ assert not child_context .element_to_widget , f"left over element_to_widget { child_context .element_to_widget } "
2138
+ assert not child_context .widgets , f"left over widgets { child_context .widgets } "
2139
+ assert not child_context .children , f"left over children { child_context .children } "
2140
+ assert not child_context .owns , f"left over owns { child_context .owns } "
2141
+ # TODO: this is not the case when an exception occurs
2142
+ # assert not child_context.children_next, f"left over children {child_context.children_next}"
2143
+ except Exception as e :
2144
+ child_context .exceptions_self .append (e )
2145
+
2132
2146
# restore context
2133
2147
self .context = context
2134
2148
if child_context .exceptions_self or child_context .exceptions_children and not child_context .exception_handler :
@@ -2163,14 +2177,6 @@ def _remove_element(self, el: Element, default_key: str, parent_key):
2163
2177
if el in context .element_to_widget :
2164
2178
del context .element_to_widget [el ]
2165
2179
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
2180
2175
2181
def _visit_children (self , el : Element , default_key : str , parent_key : str , f : Callable ):
2176
2182
assert self .context is not None
0 commit comments