Skip to content

Commit

Permalink
Fix ResizeObserver.disconnect
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zzzzBov authored Aug 2, 2024
1 parent 78cfd7d commit a000c90
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mocks/resize-observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ class MockedResizeObserver implements ResizeObserver {
};

disconnect = () => {
this.observationTargets.clear();

for (const node of this.observationTargets) {
const targetObservers = state.targetObservers.get(node);

Expand All @@ -100,6 +98,8 @@ class MockedResizeObserver implements ResizeObserver {
}
}
}

this.observationTargets.clear();
};
}

Expand Down

0 comments on commit a000c90

Please sign in to comment.