From b498ac11790b6d93ee89a3516a434ccf4aff8acc Mon Sep 17 00:00:00 2001 From: Kara Date: Tue, 18 Jun 2024 16:05:44 -0700 Subject: [PATCH] fix imagesrcset bug (#133) * 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 * Update dist/performance.js Co-authored-by: Barry Pollard --------- Co-authored-by: Barry Pollard Co-authored-by: Barry Pollard --- dist/performance.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/performance.js b/dist/performance.js index 1bcc287..5a7cc28 100644 --- a/dist/performance.js +++ b/dist/performance.js @@ -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;