Skip to content

Commit

Permalink
fix imagesrcset bug (#133)
Browse files Browse the repository at this point in the history
* fix imagesrcset bug

28% of Angular 17 apps using the image directive have been
missing performance data due to errors. Looking into it,
it seems that `link.imagesrcset` is undefined in some of
these cases. Grabbing the attribute instead of the prop with
`link.getAttribute` fixes the issue.

See example failure: https://www.webpagetest.org/result/240618_AiDc8Y_E9D/3/details/
See example fix: https://www.webpagetest.org/result/240618_AiDcZ3_E78/2/details/

* Update dist/performance.js

Co-authored-by: Barry Pollard <[email protected]>

* Update dist/performance.js

Co-authored-by: Barry Pollard <[email protected]>

---------

Co-authored-by: Barry Pollard <[email protected]>
Co-authored-by: Barry Pollard <[email protected]>
  • Loading branch information
3 people authored Jun 18, 2024
1 parent 75dfecf commit b498ac1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dist/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function getLcpPreloadInfo(rawDoc, lcpUrl) {

let src = link.href;
if (link.hasAttribute('imagesrcset')) {
src = splitSrcSet(link.imagesrcset).find(src => src == lcpUrl);
src = splitSrcSet(link.getAttribute('imagesrcset'))?.find(src => src == lcpUrl);
}

return src == lcpUrl;
Expand Down

0 comments on commit b498ac1

Please sign in to comment.