Skip to content

Commit a000c90

Browse files
authored
Fix ResizeObserver.disconnect
The mock `disconnect` method was clearing the collection of observed targets before attempting to remove those observed targets from the global state. This causes the collection to always be empty. This fix clears the global state before clearing the local collection of observed targets.
1 parent 78cfd7d commit a000c90

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/mocks/resize-observer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ class MockedResizeObserver implements ResizeObserver {
8585
};
8686

8787
disconnect = () => {
88-
this.observationTargets.clear();
89-
9088
for (const node of this.observationTargets) {
9189
const targetObservers = state.targetObservers.get(node);
9290

@@ -100,6 +98,8 @@ class MockedResizeObserver implements ResizeObserver {
10098
}
10199
}
102100
}
101+
102+
this.observationTargets.clear();
103103
};
104104
}
105105

0 commit comments

Comments
 (0)