Skip to content

Commit c9283ee

Browse files
committed
Use nextPaintTime
1 parent ba01317 commit c9283ee

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: src/attribution/onINP.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ export const onINP = (
261261
return intersectingLoAFs;
262262
};
263263

264-
const attributeLoAFDetails = (attribution: INPAttribution, value: number) => {
264+
const attributeLoAFDetails = (attribution: INPAttribution) => {
265265
// If there is no LoAF data then nothing further to attribute
266266
if (!attribution.longAnimationFrameEntries?.length) {
267267
return;
@@ -330,8 +330,7 @@ export const onINP = (
330330
? lastLoAF.startTime + lastLoAF.duration
331331
: 0;
332332
if (lastLoAFEndTime >= interactionTime + inputDelay + processingDuration) {
333-
totalPaintDuration =
334-
attribution.interactionTime + value - lastLoAFEndTime;
333+
totalPaintDuration = attribution.nextPaintTime - lastLoAFEndTime;
335334
}
336335

337336
if (longestScriptEntry && longestScriptSubpart) {
@@ -345,7 +344,8 @@ export const onINP = (
345344
attribution.totalStyleAndLayoutDuration = totalStyleAndLayoutDuration;
346345
attribution.totalPaintDuration = totalPaintDuration;
347346
attribution.totalUnattributedDuration =
348-
value -
347+
interactionTime +
348+
attribution.nextPaintTime -
349349
totalScriptDuration -
350350
totalStyleAndLayoutDuration -
351351
totalPaintDuration;
@@ -407,7 +407,7 @@ export const onINP = (
407407
totalUnattributedDuration: undefined,
408408
};
409409

410-
attributeLoAFDetails(attribution, metric.value);
410+
attributeLoAFDetails(attribution);
411411

412412
// Use `Object.assign()` to ensure the original metric object is returned.
413413
const metricWithAttribution: INPMetricWithAttribution = Object.assign(

0 commit comments

Comments
 (0)