Skip to content

Commit d28300b

Browse files
authored
fix(core): prevent exponential traversal in _dialogClosed and _onRootViewReset (#11220)
Both methods used eachDescendant to walk the full subtree, then each visited child recursively called the same method—which walked its own subtree again. For a tree of depth n this produced O(2^n) visits. Replace eachDescendant with eachChild so each node is visited exactly once via natural recursion, reducing traversal to O(n).
1 parent a051213 commit d28300b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/core/ui/core/view-base/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ export abstract class ViewBase extends Observable {
15021502
* Method is intended to be overridden by inheritors and used as "protected"
15031503
*/
15041504
public _dialogClosed(): void {
1505-
eachDescendant(this, (child: ViewBase) => {
1505+
this.eachChild((child: ViewBase) => {
15061506
child._dialogClosed();
15071507

15081508
return true;
@@ -1513,7 +1513,7 @@ export abstract class ViewBase extends Observable {
15131513
* Method is intended to be overridden by inheritors and used as "protected"
15141514
*/
15151515
public _onRootViewReset(): void {
1516-
eachDescendant(this, (child: ViewBase) => {
1516+
this.eachChild((child: ViewBase) => {
15171517
child._onRootViewReset();
15181518

15191519
return true;

0 commit comments

Comments
 (0)