Skip to content

Commit 1c7e678

Browse files
rshestfacebook-github-bot
authored andcommitted
Handle the case when PerformanceObserver.observe is called multiple times
Summary: [Changelog][Internal] Addresses the corresponding TODO in code, to make sure that PerformanceObserver.observe may be called multiple times with different entry types to observe. Reviewed By: christophpurrer Differential Revision: D41686237 fbshipit-source-id: 4287f63f7e71e5b1056d30ed616149841ba4f892
1 parent 862a99c commit 1c7e678

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Libraries/WebPerformance/PerformanceObserver.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ export default class PerformanceObserver {
199199
(_observedEntryTypeRefCount.get(type) ?? 0) + 1,
200200
);
201201
}
202-
// TODO: Handle correctly the cases when "observe" is called multiple times
203-
// on the same observer (potentially with different entry types)
202+
// The same observer may have "observe" called multiple times,
203+
// with different entry types
204+
const observerData = _observers.get(this);
205+
if (observerData !== undefined) {
206+
entryTypes = new Set([...entryTypes, ...observerData.entryTypes]);
207+
}
204208
_observers.set(this, {entryTypes, callback: this._callback});
205209
}
206210

0 commit comments

Comments
 (0)