Explorar o código

#338 avoid traversing children multiple times

Falko Schindler %!s(int64=2) %!d(string=hai) anos
pai
achega
f284f0a5fe
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      nicegui/updates.py

+ 3 - 1
nicegui/updates.py

@@ -28,7 +28,9 @@ async def loop() -> None:
     '''Repeatedly updates all elements in the update queue.'''
     while True:
         elements: Dict[int, 'Element'] = {}
-        for _, value in update_queue.items():
+        for id, value in sorted(update_queue.items()):  # NOTE: sort by element ID to process parents before children
+            if id in elements:
+                continue
             element: 'Element' = value[0]
             for id in element.collect_descendant_ids():
                 elements[id] = element.client.elements[id].to_dict()