mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Don't use getAttribute
if we don't need to
This commit is contained in:
parent
816acc6984
commit
a2ae67509d
@ -12,17 +12,11 @@ function hide(image) {
|
|||||||
image.classList.add("d-lazyload");
|
image.classList.add("d-lazyload");
|
||||||
image.classList.add("d-lazyload-hidden");
|
image.classList.add("d-lazyload-hidden");
|
||||||
|
|
||||||
imageSources.set(image, {
|
imageSources.set(image, { src: image.src, srcset: image.srcset });
|
||||||
src: image.getAttribute("src"),
|
|
||||||
srcSet: image.getAttribute("srcset")
|
|
||||||
});
|
|
||||||
image.removeAttribute("srcset");
|
image.removeAttribute("srcset");
|
||||||
|
|
||||||
image.setAttribute(
|
image.src = image.dataset.smallUpload || LOADING_DATA;
|
||||||
"src",
|
delete image.dataset.smallUpload;
|
||||||
image.getAttribute("data-small-upload") || LOADING_DATA
|
|
||||||
);
|
|
||||||
image.removeAttribute("data-small-upload");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore an image when onscreen
|
// Restore an image when onscreen
|
||||||
@ -42,9 +36,7 @@ function show(image) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
copyImg.src = sources.src;
|
copyImg.src = sources.src;
|
||||||
if (sources.srcSet) {
|
copyImg.srcset = sources.srcset || copyImg.srcset;
|
||||||
copyImg.srcset = sources.srcSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
copyImg.style.position = "absolute";
|
copyImg.style.position = "absolute";
|
||||||
copyImg.style.top = 0;
|
copyImg.style.top = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user