Skip to content

Commit

Permalink
Fix INP durationThreshold bug when set to 0 (#372)
Browse files Browse the repository at this point in the history
When INP's `durationThreshold` was set to a value of `0`, it would actually
ignore all values under 40 ms because the logical (||) operator was used.

Use nullish coalescing operator instead to fix this bug.
  • Loading branch information
nicholasray authored Sep 27, 2023
1 parent 27db8a0 commit 4b769ff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/onINP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const onINP = (onReport: INPReportCallback, opts?: ReportOpts) => {
// and performance. Running this callback for any interaction that spans
// just one or two frames is likely not worth the insight that could be
// gained.
durationThreshold: opts!.durationThreshold || 40,
durationThreshold: opts!.durationThreshold ?? 40,
} as PerformanceObserverInit);

report = bindReporter(
Expand Down

0 comments on commit 4b769ff

Please sign in to comment.