GoogleChrome / web-vitals

Essential metrics for a healthy site.
https://web.dev/vitals
Apache License 2.0
7.47k stars 410 forks source link

Expose the target element in INP attribution #479

Closed philipwalton closed 3 months ago

philipwalton commented 3 months ago

Fixes #456.

Unlike all of the other metrics, for INP there is not a simple 1-to-1 relationship between the element selector in the attribution object, and the element itself in the entries array. This means that, if the selector is not sufficient and you need access to the element itself, it's not possible to get it without re-implementing all of the INP attribution logic, which is non-trivial for INP.

To address this, this PR adds an interactionTargetElement property to the INPAttribution object, which corresponds to the element identified via the interactionTarget property.

interface INPAttribution {
  interactionTarget: string;
+  interactionTargetElement: Node | undefined;
}