소스 검색

#338 avoid traversing children multiple times

Falko Schindler 2 년 전
부모
커밋
f284f0a5fe
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  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()