Skip to content
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

pseudo-elements not directly identifiable by backend node ID #14351

Open
brendankenny opened this issue Sep 2, 2022 · 2 comments
Open

pseudo-elements not directly identifiable by backend node ID #14351

brendankenny opened this issue Sep 2, 2022 · 2 comments

Comments

@brendankenny
Copy link
Member

brendankenny commented Sep 2, 2022

Node IDs are shared between an element and any of its pseudo-elements. Any time Lighthouse tries to identify an element by DOMNodeId/backendNodeId it targets the main element, even if the culprit was actually in a pseudo-element.

I believe DOM.resolveNode usage is limited to TraceElements and AnchorElements these days, but it means that element screenshots can be wrong (e.g. if it's ::before content that had a layout shift, not the main element) and the wrong opportunities suggested (e.g. the LCP image is in an ::after, not the main element).

Same example as in #14350: https://earthy-picayune-albertonykus.glitch.me/ (the actual LCP is the ::after Lighthouse logo, but largest-contentful-paint-element identifies the whole .wrapper element as the LCP).

I'm not sure what a good solution would look like.

For TraceElements, the DOMNodeId is all you get, but e.g. for LCP there are more specific LargestImagePaint::Candidate and LargestTextPaint::Candidate trace events that give frame and root coordinates that could possibly be helpful (or hopelessly out of date by the time TraceElements is running). LargestImagePaint::Candidate also gives the URL of the image being painted, which could be used in the specific image LCP case once #14350 has a solution.

I haven't really looked into this, but the debugger protocol also lets you manipulate pseudo-elements (e.g. in the Elements panel), so they must be targetable to some extent. Maybe there's more that could be done to dig in with that.

@connorjclark
Copy link
Collaborator

connorjclark commented Sep 6, 2022

let's see if we can get the various trace surfaces to emit node ids of PEs, not just the parent. (LCP, CLS are the big ones).

also we need a way for getNodeDetails to reference a pseudo element (what would need to call it w/ a pseudo el? there's no JS way to do that so it would need to be a new function...). basically for ImageElements (for example) we would need to fill in the node property WITHOUT using in-page JS (getNodeDetails).

We also need to update FPS gatherer to use protocol to get rect bounds, since PEs are not js-exposed

@paulirish
Copy link
Member

paulirish commented Sep 18, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment