Fix onINP() attribution error due to empty entries #452
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes #451 by removing the logic) that would report
0
INP value with an emptyentries
array if the code detected that at least one interaction did happen but wasn't reported.This logic is no longer necessary (given that we observe
first-input
entries), so as long as we always includefirst-input
entries, there should never be an emptyentries
array (which is what was causing theTypeError
in #451).Note that code prior this PR assumed that any time a
first-input
entry was dispatched with aduration
value above thedurationThreshold
of theevent
observer, then there would always be a correspondoingevent
entry (and thus thefirst-input
entry was redundant). This turns out to not be true in cases where the first interaction occurs before theDOMContentLoaded
event fires, so the fix is to just always includefirst-input
entries (without trying to dedupe). (Note: this may be a Chrome bug that needs addressing, cc: @mmocny.)/cc: @ErwinHofmanRV