Skip to content

Commit

Permalink
Add guard against getEntriesByType
Browse files Browse the repository at this point in the history
  • Loading branch information
tunetheweb committed Oct 22, 2024
1 parent 1e8b4fe commit bc5db2c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/getNavigationEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/

export const getNavigationEntry = (): PerformanceNavigationTiming | void => {
const navigationEntry = performance.getEntriesByType('navigation')[0];
// JSDOM does not implement getEntriesByType: https://github.com/jsdom/jsdom/issues/3309
const navigationEntry =
self.performance &&
performance.getEntriesByType &&
performance.getEntriesByType('navigation')[0];

// Check to ensure the `responseStart` property is present and valid.
// In some cases a zero value is reported by the browser (for
Expand Down

0 comments on commit bc5db2c

Please sign in to comment.