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

ImageElements doesn't include CSS images in pseudo-elements #14350

Open
brendankenny opened this issue Sep 2, 2022 · 1 comment
Open

ImageElements doesn't include CSS images in pseudo-elements #14350

brendankenny opened this issue Sep 2, 2022 · 1 comment

Comments

@brendankenny
Copy link
Member

ImageElements loops over all elements in the page looking for computed styles looking for elements with a background-image style, but pseudo-elements can't be accessed via the DOM like that.

As a result, any image in a ::before, ::after, etc isn't included in the artifact and missed in the image audits that rely on it (OptimizedImages does pick up on them because it filters network records on resource/mime types instead, but then an audit like modern-image-formats can't join the results with ImageElements so the details don't include a node for the images)

Example page: https://earthy-picayune-albertonykus.glitch.me/ (lighthouse logo not in ImageElements despite being the only image in the page)

@connorjclark
Copy link
Collaborator

re: getElementsInDocument, only image-elements calls it w/o any parameters so that's the only instance that we are missing out on PEs. We could tack onto the data collected in-page w/ the DOM.snapshot protocol for PEs.

also
devtoolsNodePath would need to know about PEs... or we'd have to change this code:

return elem.node.devtoolsNodePath === lcpElement.node.devtoolsNodePath;

isInShadowDOM might be hard but could prob. select the element in page and figure it out.

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