Skip to content

Commit

Permalink
Merge pull request #158 from jroebu14/check-for-getEntriesByName-supp…
Browse files Browse the repository at this point in the history
…ort-before-using

check for getEntriesByName in performance before calling
  • Loading branch information
philipwalton authored Jun 2, 2021
2 parents 7fd9ce5 + 1a66913 commit 1804835
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/getFCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const getFCP = (onReport: ReportHandler, reportAllChanges?: boolean) => {

// TODO(philipwalton): remove the use of `fcpEntry` once this bug is fixed.
// https://bugs.webkit.org/show_bug.cgi?id=225305
const fcpEntry = performance.getEntriesByName('first-contentful-paint')[0];
const fcpEntry = 'getEntriesByName' in performance ? performance.getEntriesByName('first-contentful-paint')[0] : null;
const po = fcpEntry ? null : observe('paint', entryHandler);

if (fcpEntry || po) {
Expand Down

0 comments on commit 1804835

Please sign in to comment.