-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose INP target element as first class citizen in attribution #456
Comments
No strong opinions on the shape of the api in this library, or this request. But just pointing out that:
For this reason, abstracting away the list of entries down to a single target might sometimes be lossy. |
Yes but we already expose the The ask is to also expose it as an element so if you want to do some other stuff you can. Like web-vitals-extension prints it to the console so it can be used to highlight the element on hover, and view it in the Elements panel. We thought that was the only use case so decided NOT to add it just for that. But now seems we have at least one other use case here. Would be interested if we had a third use case to really make the case for including it in the library. |
This was and released in v4 and made available as |
Background
We use the INP target element instance for gaining additional insights on it upon
onINP
callback.The info we're getting is mostly the element location in DOM tree and its relation to the parent elements, which, in turn, helps us understand the element's attribution to specific application/widget within the website.
The issue
As of
[email protected]
we have to get the target by accessingmetric.entries
and choosing the rightentry.target
. For this to be aligned with whatweb-vitals
expose as INP target selector we have to use the same logic as inweb-vitals
. Today it takes the first entry with a non-null target, because of a Chrome bug. Once the bug is solved the logic for target element selection will probably change to get the first entry (metric.entries[0].target
) and then we'll have to change it in our code as well.If fact every time this logic changes (even though unlikely), we'll have to update our code as well, which makes it a leaky abstraction.
Proposed solution
Expose INP target element as a first class citizen in INP attribution.
This way the alignment between INP target selector and INP target will be abstracted away from the user and if/when the logic changes it will only have to change inside
web-vitals
.The text was updated successfully, but these errors were encountered: