Unverified Commit d04186e4 authored by Steven's avatar Steven Committed by GitHub

Fix lazy loaded images on IE 11 when no IntersectionObserver detected (#18868)

Fixes #18827 so that lazy loading does not break IE 11.
parent 4dbb65d0
......@@ -311,11 +311,6 @@ export default function Image({
lazy = true
}
if (typeof window !== 'undefined' && !window.IntersectionObserver) {
// Rendering client side on browser without intersection observer
lazy = false
}
if (src && src.startsWith('data:')) {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
unoptimized = true
......@@ -324,9 +319,8 @@ export default function Image({
useEffect(() => {
const target = thisEl.current
if (target && lazy) {
const observer = getObserver()
if (target) {
const observer = lazy && getObserver()
if (observer) {
observer.observe(target)
......@@ -335,7 +329,6 @@ export default function Image({
observer.unobserve(target)
}
} else {
//browsers without intersection observer
unLazifyImage(target)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment