Skip to content

A platform for community discussion. Free, open, simple.

FIX: Ensure lazy-load-images does not remove entire `img.style` (#16553)

David Taylor32346f4ba5a4
diff --git a/app/assets/javascripts/discourse/app/lib/lazy-load-images.js b/app/assets/javascripts/discourse/app/lib/lazy-load-images.js
index a0a2bc0fdc6..e4c523f8723 100644
--- a/app/assets/javascripts/discourse/app/lib/lazy-load-images.js
+++ b/app/assets/javascripts/discourse/app/lib/lazy-load-images.js
@@ -18,11 +18,16 @@ export function nativeLazyLoading(api) {
if (!img.complete) {
if (!img.onload) {
img.onload = () => {
- img.removeAttribute("style");
+ img.style.removeProperty("background-image");
+ img.style.removeProperty("background-size");
};
}
- img.style = `background-image: url(${img.dataset.smallUpload}); background-size: cover;`;
+ img.style.setProperty(
+ "background-image",
+ `url(${img.dataset.smallUpload});`
+ );
+ img.style.setProperty("background-size", "cover");
}
}
}),