Skip to content

Commit

Permalink
Update getEntriesByName check per style guide
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwalton committed Jun 2, 2021
1 parent 1804835 commit d47f57b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/getFCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ 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 = 'getEntriesByName' in performance ? performance.getEntriesByName('first-contentful-paint')[0] : null;
// Also, the check for `getEntriesByName` is needed to support Opera:
// https://github.com/GoogleChrome/web-vitals/issues/159
const fcpEntry = performance.getEntriesByName &&
performance.getEntriesByName('first-contentful-paint')[0];

const po = fcpEntry ? null : observe('paint', entryHandler);

if (fcpEntry || po) {
Expand Down

0 comments on commit d47f57b

Please sign in to comment.