fix: null check on elapsedTime for some browsers (#7213)

This commit is contained in:
eddie 2023-08-23 10:53:51 -07:00 committed by GitHub
parent 8c7315760a
commit bcc57e4612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,7 +2,8 @@
* Returns the time elapsed between page load and now. * Returns the time elapsed between page load and now.
* @param markName the identifier for the performance mark to be created and measured. * @param markName the identifier for the performance mark to be created and measured.
*/ */
export function calculateElapsedTimeWithPerformanceMark(markName: string): number { export function calculateElapsedTimeWithPerformanceMark(markName: string): number | undefined {
const elapsedTime = performance.mark(markName) const elapsedTime = performance.mark(markName)
if (!elapsedTime) return undefined
return elapsedTime.startTime return elapsedTime.startTime
} }