From 12cb033f7998427cfbabe8d833a7c2bd516f3b1f Mon Sep 17 00:00:00 2001 From: Ward Peeters Date: Thu, 12 May 2022 12:29:54 +0200 Subject: [PATCH] fix(gatsby-plugin-image): fix race condition (#35635) --- packages/gatsby-plugin-image/src/components/layout-wrapper.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/gatsby-plugin-image/src/components/layout-wrapper.tsx b/packages/gatsby-plugin-image/src/components/layout-wrapper.tsx index b0155f95f6199..6643a03157154 100644 --- a/packages/gatsby-plugin-image/src/components/layout-wrapper.tsx +++ b/packages/gatsby-plugin-image/src/components/layout-wrapper.tsx @@ -34,6 +34,9 @@ if (hasNativeLazyLoadSupport) { if (mainImage.complete) { mainImage.style.opacity = 1; + + // also hide the placeholder + mainImage.parentNode.parentNode.querySelector('[data-placeholder-image]').style.opacity = 0; } } }