From beafbaf4158bc851a97e02dfb90d437f5607e215 Mon Sep 17 00:00:00 2001 From: Akshay Iyer Date: Wed, 8 Nov 2017 08:45:30 +0530 Subject: [PATCH 1/4] core(image-usage): add null check for parentElement --- lighthouse-core/gather/gatherers/image-usage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthouse-core/gather/gatherers/image-usage.js b/lighthouse-core/gather/gatherers/image-usage.js index 76419ff4a516..d2a45eae2674 100644 --- a/lighthouse-core/gather/gatherers/image-usage.js +++ b/lighthouse-core/gather/gatherers/image-usage.js @@ -45,7 +45,7 @@ function collectImageElementInfo() { naturalWidth: element.naturalWidth, naturalHeight: element.naturalHeight, isCss: false, - isPicture: element.parentElement.tagName === 'PICTURE', + isPicture: !!element.parentElement && element.parentElement.tagName === 'PICTURE', usesObjectFit: computedStyle.getPropertyValue('object-fit') === 'cover' || computedStyle.getPropertyValue('object-fit') === 'contain', }; From 843de86283b5a55801c459fc084d14cd8f61bc52 Mon Sep 17 00:00:00 2001 From: Akshay Iyer Date: Wed, 8 Nov 2017 09:02:23 +0530 Subject: [PATCH 2/4] core(image-usage): add null check for parentElement --- lighthouse-core/gather/gatherers/image-usage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthouse-core/gather/gatherers/image-usage.js b/lighthouse-core/gather/gatherers/image-usage.js index 76419ff4a516..d2a45eae2674 100644 --- a/lighthouse-core/gather/gatherers/image-usage.js +++ b/lighthouse-core/gather/gatherers/image-usage.js @@ -45,7 +45,7 @@ function collectImageElementInfo() { naturalWidth: element.naturalWidth, naturalHeight: element.naturalHeight, isCss: false, - isPicture: element.parentElement.tagName === 'PICTURE', + isPicture: !!element.parentElement && element.parentElement.tagName === 'PICTURE', usesObjectFit: computedStyle.getPropertyValue('object-fit') === 'cover' || computedStyle.getPropertyValue('object-fit') === 'contain', }; From 48a609d7e3ae1eea0493c234a7f460f21177de3f Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Wed, 8 Nov 2017 12:05:11 -0800 Subject: [PATCH 3/4] add smoke test --- lighthouse-cli/test/fixtures/byte-efficiency/tester.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lighthouse-cli/test/fixtures/byte-efficiency/tester.html b/lighthouse-cli/test/fixtures/byte-efficiency/tester.html index fdf3d3afecf6..d0834d8cbb7c 100644 --- a/lighthouse-cli/test/fixtures/byte-efficiency/tester.html +++ b/lighthouse-cli/test/fixtures/byte-efficiency/tester.html @@ -51,6 +51,12 @@

Byte efficiency tester page

Hi there! +
+
From f313424de4f2284392aa758d28416c51f7f59dd2 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Wed, 8 Nov 2017 12:06:24 -0800 Subject: [PATCH 4/4] add issue link --- lighthouse-cli/test/fixtures/byte-efficiency/tester.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthouse-cli/test/fixtures/byte-efficiency/tester.html b/lighthouse-cli/test/fixtures/byte-efficiency/tester.html index d0834d8cbb7c..3167787a13ea 100644 --- a/lighthouse-cli/test/fixtures/byte-efficiency/tester.html +++ b/lighthouse-cli/test/fixtures/byte-efficiency/tester.html @@ -53,7 +53,7 @@

Byte efficiency tester page

Hi there!