Skip to content

Commit a55f430

Browse files
RSNarafacebook-github-bot
authored andcommitted
IntersectionObserver: Clean up shadow nodes after unobserve
Summary: After unobserve is called, the shadow node actually isn't deleted from the `targetToShadowNode` WeakMap. So, if the element is kept around, the shadow node will leak. We suspect this doesn't happen in practice. But, still it's good to just do this cleanup, just in case. Changelog: [General][Fixed] Fix potential leak inside IntersectionObserver Reviewed By: lunaleaps, yungsters Differential Revision: D74361644 fbshipit-source-id: 1a5ccce1486aa200fc7318c689bfa887f713c284
1 parent e6516f2 commit a55f430

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

packages/react-native/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ export function unobserve(
232232
);
233233
return;
234234
}
235+
targetToShadowNodeMap.delete(target);
235236

236237
NativeIntersectionObserver.unobserve(
237238
intersectionObserverId,
@@ -245,6 +246,7 @@ export function unobserve(
245246
);
246247
return;
247248
}
249+
targetToTokenMap.delete(target);
248250

249251
modernNativeIntersectionObserver.unobserve(
250252
intersectionObserverId,

0 commit comments

Comments
 (0)